2007-02-07
GEEK: crontab weirdness?
2007-02-07 02:19 pmOkay, so I have this crontab:
It's supposed to log the ouptut of test.py to $MROOT/log/testlog.$DATE every minute. However, although it creates the log file, the file is empty:
Now, I know that test.py is creating output--if I run it from the command line, I can see the output. And that output appears to be coming from stderr--if I run ./test.py > testlog.out, nothing is logged, but if run ./test.py 2> testlog.out, the output is logged.
I also know the ">&" redirect is C-shell syntax. So I tried it with Bourne shell syntax:
* * * * * $MROOT/test.py > $MROOT/log/testlog.$DATE 2>&1
This time, the output file was created (still empty). But now the logfile name instead of being set to this:
testlog.2007-02-07_1418
was set to this:
testlog.`date +%Y-%m-%d_%H%M`
Anyone know:
1) Why changing the redirect would cause the $DATE variable to be substituted with the string literal rather than the output of the date command?
2) Why stderr isn't being logged to the log file?
(I'm running on 10.4.8 Tiger Server).
SHELL=/bin/sh PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/Users/build/bin:/sw/bin HOME=/var/log MAILTO=dev@example.com MROOT=/Users/build DATE=`date +%Y-%m-%d_%H%M` # Nightly Processes * * * * * $MROOT/test.py >& $MROOT/log/testlog.$DATE
It's supposed to log the ouptut of test.py to $MROOT/log/testlog.$DATE every minute. However, although it creates the log file, the file is empty:
sh-2.05b# ls -al testlog* -rw-r--r-- 1 build build 0 Feb 7 14:18 testlog.2007-02-07_1418
Now, I know that test.py is creating output--if I run it from the command line, I can see the output. And that output appears to be coming from stderr--if I run ./test.py > testlog.out, nothing is logged, but if run ./test.py 2> testlog.out, the output is logged.
I also know the ">&" redirect is C-shell syntax. So I tried it with Bourne shell syntax:
* * * * * $MROOT/test.py > $MROOT/log/testlog.$DATE 2>&1
This time, the output file was created (still empty). But now the logfile name instead of being set to this:
testlog.2007-02-07_1418
was set to this:
testlog.`date +%Y-%m-%d_%H%M`
Anyone know:
1) Why changing the redirect would cause the $DATE variable to be substituted with the string literal rather than the output of the date command?
2) Why stderr isn't being logged to the log file?
(I'm running on 10.4.8 Tiger Server).
