Hey list, I have several crontabs set up to run at night and I'm not convinced they are running but of course, I'm not here to see for sure! The crontabs are like the following example; 30 20 * * * sh /home/a_user/nightlyscrips/nightly_script_1 > /home/a_user/nightlyscripts/`date +%d-%m-%Y--%H-%M-%S`.log However, if this would have successfully ran last night I would surely expect to see 09-06-2009--20-30-00.log in the nightlyscripts directory? But its not there, this goes for all my cron jobs. I have three scripts running at different times in the night all echoing out to a log file like above so I can see how they did but a week after setting them up and no log files exist. The crontabs are running under root and if I copy the command and paste it in terminal and run that from root it runs fine? I set a cron tab up this morning just to see what happens; 35 08 * * * touch /home/a_user/test_file This worked fine, the file was created. Whats happening to my other cron tabs? How can I diagnose the problem? Any help is greatly appreciated. Thanks for reading! Regards, James ;) -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GIT/MU/U dpu s: a--> C++>$ U+> L++> B-> P+> E?> W+++>$ N K W++ O M++>$ V- PS+++ PE++ Y+ PGP t 5 X+ R- tv+ b+> DI D+++ G+ e(+++++) h--(++) r++ z++ ------END GEEK CODE BLOCK------
On 2009-06-10 10:08, James Bensley wrote:> Hey list, > > I have several crontabs set up to run at night and I'm not convinced > they are running but of course, I'm not here to see for sure! > The crontabs are like the following example; > > 30 20 * * * sh /home/a_user/nightlyscrips/nightly_script_1 > > /home/a_user/nightlyscripts/`date +%d-%m-%Y--%H-%M-%S`.logSomewhere deeply hidden in "man 5 crontab", there is the paragraph: The "sixth" field [...] Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input. -- Paul Bijnens, Xplanation Technology Services Tel +32 16 397.525 Interleuvenlaan 86, B-3001 Leuven, BELGIUM Fax +32 16 397.552 *********************************************************************** * I think I've got the hang of it now: exit, ^D, ^C, ^\, ^Z, ^Q, ^^, * * quit, ZZ, :q, :q!, M-Z, ^X^C, logoff, logout, close, bye, /bye, ~., * * stop, end, ^]c, +++ ATH, disconnect, halt, abort, hangup, KJOB, * * ^X^X, :D::D, kill -9 1, kill -1 $$, shutdown, init 0, Alt-F4, * * Alt-f-e, Ctrl-Alt-Del, Alt-SysRq-reisub, Stop-A, AltGr-NumLock, ... * * ... "Are you sure?" ... YES ... Phew ... I'm out * ***********************************************************************
James Bensley wrote on Wed, 10 Jun 2009 09:08:52 +0100:> 30 20 * * * sh /home/a_user/nightlyscrips/nightly_script_1 > > /home/a_user/nightlyscripts/`date +%d-%m-%Y--%H-%M-%S`.logchange the ">" to "&>" to get all output. Furthermore, there might be a problem to run date in this environment. The path in cron is not the same as in your root account. Change the logfile to a fixed name and it will work. Btw, there is no need for the logs. If you omit them you get the output mailed. Kai -- Kai Sch?tzl, Berlin, Germany Get your web at Conactive Internet Services: http://www.conactive.com
James Bensley wrote:> The crontabs are like the following example; > > 30 20 * * * sh /home/a_user/nightlyscrips/nightly_script_1 > > /home/a_user/nightlyscripts/`date +%d-%m-%Y--%H-%M-%S`.log > >I'm a big fan of keeping the contents of crontab very simple. The only thing I like to see in crontab is the path to the script, and the script does all the tricky stuff. If the script isn't called, you know cron is at fault. If the script is called and failed, then you know the script is broken. I find it makes it easy to determine where the problem is by making life very simple for cron. Just my 2c worth :) Ian