Hello all,
I have a script that I am trying to execute and redirect the output to a file, but I have trouble in redirection. The cron job is running properly as I see it in the mail.
You have to take some initiative. Try something different. Does your script direct the output somewhere else? Does it play around with file descriptors? Did you check your mail? If it's not that sensitive, post the script so we can see what it's doing. Change your cronjob to write to /tmp instead of "some_location". Play around with it a bit.
There's no reason I can think why it shouldn't do what you expect, and from what you've given us it should, but it doesn't help if ypur script can only run at 4 in the morning!
Actually the script runs every 4 hours, I just displayed it as 4 to avoid the hassle. And I cannot display the script as it doesn't belong to me and it belongs to a business critical application. I saw the script and everything seems to be straight forward. But I don't understand the reason for it to not redirect the output.
Check "/some_location" for a file name .log . If it's there, that tells us that your cron won't do command expansion (the backticks), and you'll have to find another way to add that to the log file name (maybe through a wrapper script)
Write the log file to /tmp / /var/tmp / some other location that's guaranteed to be writeable and not full
Check the mail for the user owning the crontab entry. Any output written to stdout/stderr is usually sent via local mail
Check the script itself for any stuff like text exec 1>... exec 2>...
as those are redirections that take precedence over anything you might do from within cron
As scottn said, show some initiative, instead of feeding us one tidbit at a time.
cron run commands on a subshell. try running your command on its own shell by passing the entire command as an argument to the shell. also, use the full path of date and bash or sh.