[NTLUG:Discuss] testing and results Re: crontab issue

Fred James fredjame at fredjame.cnc.net
Thu Mar 15 11:50:32 CDT 2007


Robert Citek wrote:

>What distro?  For example, here's a command using "su" run on FC4:
>
># su - foo date
>/bin/date: /bin/date: cannot execute binary file
>
>The same command on Ubuntu 6.06:
>
># su - foo date
>Thu Mar 15 10:25:15 CDT 2007
>
>Both were run as user root.
>
>FWIW, here's a sample crontab for root under Ubuntu 6.06:
>
>SHELL=/bin/bash
>* * * * * date > /tmp/date.cron.1
>* * * * * date +%Y > /tmp/date.cron.2
>* * * * * date +\%Y > /tmp/date.cron.3
>* * * * * su - foo date +\%Y > /tmp/date.cron.4
>* * * * * su - foo "date +\%Y > /tmp/date.cron.5"
>
>All of the above work with the exception of cron.2.  That's because %Y
>is interpreted by cron before being passed on to the date command.  The
>cron.4 file differs from the cron.5 file in that cron.4 is owned by root
>while cron.5 is owned by foo.  I got no errors about stdin, stderr, or
>stdout.
>
>HTH,
>- Robert
>
>Fred James wrote:
>  
>
>>All
>>First, a thank you to everyone who responded with suggestions.  I used 
>>those suggestions to put together a series of test and I include a brief 
>>description of the whole thing herein.  Unless someone has a further 
>>suggestion, it looks like I could live with number 6 and redirect stderr 
>>to /dev/null.
>>
>>Thank you in advance for any help you may be able to offer
>>Regards
>>Fred James
>>
>>[Test description]
>>I put 9 lines into the crontab (like those shown below) and I have 
>>grouped the results in the three main categories (also below).  To 
>>summarize however, number 6 while producing error messages, is the only 
>>one that used both the arguments and the user's environmental variables.
>>
>>[error messages]
>>1-5 had no error messages
>>6-7 each had two error messages: stdin: is not a tty, and: TERM 
>>environment variable not set.
>>8-9 each had one error message: stdin: is not a tty
>>
>>[arguments]
>>1,2,and 6 used the arguments
>>3,5,7,and 9 had no arguments given, so of course they did use them
>>4,and 8 had arguments but didn't use them
>>
>>[user's environment (.profile)]
>>1-5 did not use the user's environmental values
>>6-9 did use the user's environmental values
>>
>>(1) 5 * * * * /username/program 1 2 3 4 5 one two three four 2> 
>>/tmp/errorfile1
>>(2) 6 * * * * su username /username/program 1 2 3 4 5 one two three four 
>>2> /tmp/errorfile2
>>(3) 7 * * * * su username /username/program 2> /tmp/errorfile3
>>(4) 8 * * * * su username -c /username/program 1 2 3 4 5 one two three 
>>four 2> /tmp/errorfile4
>>(5) 9 * * * * su username -c /username/program 2> /tmp/errorfile5
>>(6) 10 * * * * su - username /username/program 1 2 3 4 5 one two three 
>>four 2> /tmp/errorfile6
>>(7) 11 * * * * su - username /username/program 2> /tmp/errorfile7
>>(8) 12 * * * * su - username -c /username/program 1 2 3 4 5 one two 
>>three four 2> /tmp/errorfile8
>>(9) 13 * * * * su - username -c /username/program 2> /tmp/errorfile9
>>    
>>
Robert Citek
Distro: Mandrake/Mandriva 9.x, 10.x, and 2006
Problem: as root with root crontab, it seemed to be working (more 
testing maybe?), but as another user with their crontab there are still 
some issues.
One glaring issue is that the cron itself ignore the DST set by TZ.  In 
my case I can live with it, at least now, but ...
Regards
Fred James



More information about the Discuss mailing list