adding date to cron log


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting adding date to cron log
# 1  
Old 09-18-2006
adding date to cron log

Hi. I'm trying to output the current date to a cronjob log file. Nothing seems to work, echo $(date), echo `date` or just date in the script. I'm using /sbin/sh

Any ideas? Thanks, John
# 2  
Old 09-18-2006
The below works to make the logfile from a cron entry date specific:

00 11 * * * /scripts/scriptname.sh > /logs/log`date +%d%m%y`.log 2>&1

Or in the script:

DATE_STAMP=` date +%Y%m%d`

echo ${DATE_STAMP}

--------------

FILE_NAME=file_${DATE_STAMP}.log

do something > $FILE_NAME
# 3  
Old 09-18-2006
Thanks. Actually, all of these work along with echo $(date) etc. The problem seems to be that the date echo is being overwritten by an stty error in the .profile which is being called next...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete log files content older than 30 days and append the lastest date log file date

To delete log files content older than 30 days and append the lastest date log file date in the respective logs I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs This is my script cd... (2 Replies)
Discussion started by: sreekumarhari
2 Replies

2. UNIX for Dummies Questions & Answers

Adding hours and minutes to current date (Only to date not to time)

Hi, I want to add some hours and minutes to the current date. For example, if the current date is "July 16, 2012 15:20", i want to add 5 hours 30 minutes to "July 16, 2012 00:00" not to "July 16, 2012 15:20". Please help. Thanks! (4 Replies)
Discussion started by: manojgarg
4 Replies

3. Shell Programming and Scripting

Adding a cron job that will execute everyday at 14:50 hrs

Hi I want to execute a cron job everyday at 14:50 hrs. I have a script like this: TMP_FILE="/tmp/tmpcron.txt" RES=0 /usr/bin/crontab -l >> $TMP_FILE ADD_JOB="50 14 * * * /opt/mypath/scriptname.sh" grep "scriptname.sh" $TMP_FILE >> /dev/null JOB_NOT_EXIST=$? if test $JOB_NOT_EXIST... (2 Replies)
Discussion started by: saurabhkoar
2 Replies

4. Shell Programming and Scripting

Adding days to system date then compare to a date

Hi! I am trying to read a file and every line has a specific date as one of its fields. I want to take that date and compare it to the date today plus 6 days. while read line do date=substr($line, $datepos, 8) #date is expected to be YYYYMMDD if ; then ...proceed commands ... (1 Reply)
Discussion started by: kokoro
1 Replies

5. Shell Programming and Scripting

Adding a new root cron job

Hi there, I have over 2000 systems (mainly Solaris) and I want to write a script that inserts a new root cronjob on each of those servers. obviously just adding a line to /var/spool/cron/crontabs/root looks like the easiest way, but i really dont want to have to send a HUP to crond on all boxes ... (3 Replies)
Discussion started by: rethink
3 Replies

6. UNIX for Dummies Questions & Answers

cron-apt - adding X-headers

Hi, We use a ticket system for our IT queries called OTRS. Emails sent to that system are placed in ticket queues. OTRS reads X- headers in emails as described here: http://dev.jasonpruim.com/otrs/doc/X-OTRS-Headers.txt We would like to be able to configure cron-apt to place certain X-... (1 Reply)
Discussion started by: karuna
1 Replies

7. Shell Programming and Scripting

adding a user to cron.allow

Hello all, I have solaris 10. I have have a script that installs crontab for a user. I want to add some more features to this script. I want to check whether the user exists in etc/cron.d/cron.allow ... if yes then continue the script without adding .... if not, then add that user to the... (6 Replies)
Discussion started by: MisterKhan
6 Replies

8. UNIX for Dummies Questions & Answers

Adding date and time to a log file

Morning all Im hoping you can help me. We have a nice new oracle server :( and are needing to move some files around for EDI and BACS. The server runs windows but has an app called MKS toolkit installed which give unix commands. (Needed for the oracle stuff) I have had a go using dos commands... (2 Replies)
Discussion started by: ltodd2
2 Replies

9. UNIX for Dummies Questions & Answers

Adding date to oracle exp log

I want to add a date/time stamp to the front of each line in an oracle exp log file. I created a shell script: rm -f expTest.Pipe mknod expTest.Pipe p date "+%Y.%m.%d %T" nawk -f expTest.nawk expTest.Pipe > expTest.Tlog & exp userid=UID/PW@DB file=expTest.dmp log=expTest.log owner=OWNER 2>>... (1 Reply)
Discussion started by: KrisOracleGuy
1 Replies

10. AIX

AIX and cron logs filtering ?: /etc/cronlog.conf, /var/adm/cron/log

Hi, I can use 'crontabs –e' and do all the scheduling I like. However I would like to auto send myself just the cronjobs logs that fail. That is to say the PIDs that fail and the related lines with those PID’s only. (Not the full set of logs) Has anyone done this work? Or does an AIX 5.3 tool... (0 Replies)
Discussion started by: Keith Johnson
0 Replies
Login or Register to Ask a Question