LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-10-2005, 03:20 PM   #1
@ngelot
Member
 
Registered: Oct 2004
Posts: 84

Rep: Reputation: 15
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!
 
Old 07-10-2005, 03:25 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
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
 
Old 07-10-2005, 03:39 PM   #3
@ngelot
Member
 
Registered: Oct 2004
Posts: 84

Original Poster
Rep: Reputation: 15
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

Last edited by @ngelot; 07-10-2005 at 03:41 PM.
 
Old 07-10-2005, 04:08 PM   #4
@ngelot
Member
 
Registered: Oct 2004
Posts: 84

Original Poster
Rep: Reputation: 15
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!
 
Old 07-11-2005, 05:18 AM   #5
twantrd
Senior Member
 
Registered: Nov 2002
Location: CA
Distribution: redhat 7.3
Posts: 1,440

Rep: Reputation: 52
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 09:09 AM
cron.allow and cron.deny in slackware? tl64 Slackware 5 10-13-2005 10:44 PM
No More Cron Mail, Cron Error? Xhost Linux - General 3 07-26-2004 05:28 PM
[cron][mdk9.1]cron deamon seems to ignore some task... yannrichet Linux - Newbie 5 06-26-2003 10:57 AM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 03:30 PM


All times are GMT -5. The time now is 09:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration