LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help with cron (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-cron-341907/)

@ngelot 07-10-2005 02:20 PM

Help with cron
 
I would like my cron-job output in a log file and made this test-script:
Code:

#!/bin/sh
echo I'm a git

and with:
Code:

# sh test.sh
I get the right output, but when I try to make it a cron-job nothing happen:
Code:

01 * * * * /root/test.sh>>/logs/test.log>/dev/null 2>&1
I don't want any emails, I just want the output of test.sh to be written at the end of test.log....

It won't work - what am I doing wrong?

test.log exists and root has rwx to the file...

Thanks!

trickykid 07-10-2005 02:25 PM

root might have rwx to the file as a user but is the file executable? Does it work from a command line without specifying its a sh script?

chmod +x test.sh

@ngelot 07-10-2005 02:39 PM

Yep!
Code:

-rwx--x--x  1 root root    0 Jul 10 20:34 test.log
and

Code:

-rwxr-xr-x  1 root root  42 Jul 10 21:01 test.sh

@ngelot 07-10-2005 03:08 PM

Found it out my self - I didn't understand the difference between output 1 and 2.

This is the correct way:

10 * * * * /root/test.sh 1>/logs/test.log 2>&1

as in 1 (if OK) then print output in test.log and 2 (if not OK) do the same....

Thanks!

twantrd 07-11-2005 04:18 AM

Quote:

as in 1 (if OK) then print output in test.log and 2 (if not OK) do the same....
Hmm, i guess that's right. But to be more exact:

1= standard output
2= standard error

Those are what the numbers mean.

-twantrd


All times are GMT -5. The time now is 12:44 PM.