Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unix redirection question

Status
Not open for further replies.

n0radanj0

IS-IT--Management
Sep 1, 2008
2
IE
I am trying to run a crontab job which is set up as follows
$ crontab -l
00 04 * * * /prd/edt/gisactive/bin/extract_gis.csh 2>&1 > /prd/edt/gisactive/log/`date +"%Y%m%d_%H%M"`_gisextract.log

The output produced it like this

-rw-r--r-- 1 gisactiv staff 684 Sep 01 04:00 Mon Sep 1 04:00:00 BST 2008

But I cannot read this and it does not append the log name to end of the file. Is there a problem with my syntax? Thanks any suggestions would be very helpful.
 
As far as I can see that should work, it certainly did in a test I have just done. Can't you read the file '1'. The only other thing I can think of is that the & is missing or ignored somehow.

I want to be good, is that not enough?
 
You didn't say what Operating System you are using. I tried this on Solaris 8 and it produced an error message saying "sh: cannot create".

This highlights the point that Cron jobs use Bourne Shell commands, but unfortunately not actually in a their own shell, hence no 'substitution'.

Please see:
man cron
man crontab

for the way your Operating System uses cronjobs.

You might be able to read your file with:
cat /prd/edt/gisactive/log/Mon*


I hope that helps.

Mike
 
I think it should be:
00 04 * * * /prd/edt/gisactive/bin/extract_gis.csh > /prd/edt/gisactive/log/`date +"%Y%m%d_%H%M"`_gisextract.log 2>&1
 
The % character as a special meaning for cron ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the reminder PHV, I've come up against this before and needed to escape (with \) each % before it would work as desired.

Can you give this a go?

I want to be good, is that not enough?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top