why the date format dont work in crontab


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users why the date format dont work in crontab
# 1  
Old 06-28-2008
why the date format dont work in crontab

Hi

I tried to put a cron job which pipes the logfile appended to date +%d
but it didnt work .

anyone know how to make this happen

thanks in advance
-prasad
# 2  
Old 06-28-2008
not seeing any code or any error messages, it's hard to tell what the problem is - maybe a $PATH problem ?
# 3  
Old 06-29-2008
at least u can put crontab -l here
# 4  
Old 06-29-2008
sorry about the delay.

this is the crontab entry.

0 17 * * * /home/oracle/bin/move_archlog.ksh > /home/oracle/log/move_archlog.cron.log.`date +%m%d%y` 2>&1

So it is creating logfile name as
move_archlog.cron.log.Sat May 31 17:00:00 PDT 2008
instead of
move_archlog.cron.log.060208
# 5  
Old 06-30-2008
works fine for me on freebsd - what *nix OS you running?

p.s if you're going to use dated logs, it's best to use the universal standard of YYYYMMDD
# 6  
Old 06-30-2008
I tried both in solaris and AIX . but I could not make it work.
# 7  
Old 06-30-2008
Do this.

0 17 * * * /home/oracle/bin/move_archlog.ksh > /home/oracle/log/move_archlog.cron.log.`date +\%m\%d\%y` 2>&1

You may need to escape the %s.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Shell script - if statements dont work

hi all, i have made a shell script and it runs until it reaches the if statement, doesn't the ! mean only if the command fails it will echo me that message and then exit can anyone please help me what is wrong with my code? many thanks, rob #!/bin/bash echo "is this archive... (10 Replies)
Discussion started by: robertkwild
10 Replies

2. UNIX for Dummies Questions & Answers

Rename all Files in a UNIX Directory from one date format to another date format

Hi Unix Gurus, I would like to rename several files in a Unix Directory . The filenames can have more than 1 underscore ( _ ) and the last underscore is always followed by a date in the format mmddyyyy. The Extension of the files can be .txt or .pdf or .xls etc and is case insensitive ie... (1 Reply)
Discussion started by: pchegoor
1 Replies

3. Programming

Breakpoints dont work in Codeblocks, code does not build

Hey so I've written a program and it crashes every time I run it. I tried placing breakpoints to see what was going but to my surprise they do not work! I've placed them anywhere and they do not stop the execution of the program. In fact if I add code and hit rebuild it doesn't even build that... (1 Reply)
Discussion started by: Cambria
1 Replies

4. UNIX for Dummies Questions & Answers

keyboard and mouse dont work after sometime from boot in linux.

when i started booting linux ,after sometime both the mouse and the keyboard are getting freeze and wont respond(also the system gets hanged and all the process running dont go forward) ,nothing seem to work. Keeping in mind that it will work after sometime ,i waited for one hour also ,but... (1 Reply)
Discussion started by: sanjay.login
1 Replies

5. Shell Programming and Scripting

Substitution in a file dont work with an Array in filename

Hi. I´ve a script that should substitude the 8th line in a file called xxx.num6. The "xxx" is set by an array filled with this command: j=0 for Par in *.sys ; do Par=`echo $Par | sed 's/\(.*\).sys/\1/'` ; Par2="$Par" ; echo "${Par2}" j=$((j + 1)); done Now i try... (0 Replies)
Discussion started by: Lock3
0 Replies

6. UNIX for Dummies Questions & Answers

Changing from Excel date format to MySQL date format

I have a list of dates in the following format: mm/dd/yyyy and want to change these to the MySQL standard format: yyyy-mm-dd. The dates in the original file may or may not be zero padded, so April is sometimes "04" and other times simply "4". This is what I use to change the format: sed -i '' -e... (2 Replies)
Discussion started by: figaro
2 Replies

7. Shell Programming and Scripting

convert date format to mysql date format in log file

I have a comma delimited log file which has the date as MM/DD/YY in the 2nd column, and HH:MM:SS in the 3rd column. I need to change the date format to YYYY-MM-DD and merge it with the the time HH:MM:SS. How will I got about this? Sample input 02/27/09,23:52:31 02/27/09,23:52:52... (3 Replies)
Discussion started by: hazno
3 Replies

8. Shell Programming and Scripting

if [ -z echo foo | egrep -e 'regexp' != '' ] -> dont work

Hallo, I need to test a String (a special ip number-string). So I want to run that: ipadress=172.0.0.0 # for debugging: echo $ipadress | egrep -e '172\.?\.??\.??$' # the test that doesnt work if test -z `echo $ipadress | egrep -e '172\.?\.??\.??$'` != "" then echo "match" else... (1 Reply)
Discussion started by: wiseguy
1 Replies

9. Shell Programming and Scripting

Date Format Does not work in Shell

I'm am able to format the date in the unix prompt using NOW=$(date +"%d%m%y"). However, when i put the same format into a shell script, it errors out with the followign. sintax error on line 4: `NOW=$' unexpected. #!/bin/ksh EXP_LOC=/u02/oradata/exports NOW=$(date +"%d%m%y") ... (8 Replies)
Discussion started by: mrx1350
8 Replies

10. Filesystems, Disks and Memory

OS X / fsck / apps dont work no control panel

Alright. My neighbor kid brings me his iBook and says nothing works. He decided to move the file system to his likeness and that semed to create the problems. Now he doesn't have access rights to his home. I have run fsck over and over again and I keep getting ** fs modified ** I have also... (0 Replies)
Discussion started by: maxwell
0 Replies
Login or Register to Ask a Question