LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-31-2006, 03:33 PM   #1
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Rep: Reputation: 30
need help setting crontab


this is the output of cat /etc/crontab

Quote:
# m h dom mon dow user command
17 * * * * root run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.daily
47 6 * * 7 root test -x /usr/sbin/anacron || run-parts --report /etc/cron.weekly
52 6 1 * * root test -x /usr/sbin/anacron || run-parts --report /etc/cron.monthly
1 * * * * root root /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.dude -update >/home/elmo/awstats.dude.html
5 2 * * * root root /backup/backup_a
6 2 * * * root root /backup/backup_b
7 2 * * * root root /backup/backup_c
8 2 * * * root root /backup/backup_d
This last 4 lines are suppose to create 4 new files in the /backup folder and they are not working, the cron log is showing that the commands were run but when I browse to check the files created, the 4 backups are not there. The backup scripts work just fine when run from the command line. I need help to do this correctly. Thanks.
 
Old 08-31-2006, 03:43 PM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,125

Rep: Reputation: 164Reputation: 164
If the logs show the scripts being run, but no output is produced, the problem is probably inside the scripts themselves.

Do you use the full path to commands? For example, /usr/bin/tar instead of tar? cron runs with a different environment to a logged in user, paths and environment variables may not be what the script needs.
 
Old 08-31-2006, 04:47 PM   #3
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
No, I just had tar without any path, I changed it now to see if it works. Thanks.
 
Old 09-01-2006, 09:24 AM   #4
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
I didn't work, I found another thread talking about the same problem and the guys says that he restarted cron and now it works. I will try it to, do you know anything about that?
 
Old 09-01-2006, 10:55 AM   #5
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
If you're referring to http://www.linuxquestions.org/questi...d.php?t=479234,
then your problem is different from the other one. Your cron jobs work just fine and just don't do what they're expected to. The other post is about cron not detecting any changes to the crontab settings, without restarting cron service.

As for your problem, start off by catching any output of your backup script into a file, by modifying the crontab command like this:
(/backup/backup_a 2>&1) > /tmp/backup_a.out
and likewise for the other ones.

If all goes well, you should get at least some clues of what's going wrong (ie error messages in /tmp/backup_a.out).

Most likely, they're related to issues with environment variables like $PATH, similar to the issue with tar.
 
Old 09-04-2006, 10:34 PM   #6
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
I tried and then restarted cron to make sure it runs. I tried several times is like the cron weren't reading the file, It did not create any files nor in the backup folder or in tmp/ even thou the log says the script was executed. Any ideas what this could be? thank you again.
 
Old 09-05-2006, 04:09 AM   #7
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
So the script executes but doesn't seem to do anything? Try putting a simple command like "date" or "whoami" at the top. If you then catch stdout in a file (ie in /tmp), you should see at least the output of that command, just to confirm that the script runs fine.
If it does run fine, then the lack of output may be simply due to the executed commands.
 
Old 09-05-2006, 10:48 AM   #8
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
5 2 * * * root root (/backup/backup_a 2>&1) >/tmp/a.cron.out
6 2 * * * root root (/backup/backup_b 2>&1) > /tmp/b.cron.out
7 2 * * * root root (/backup/backup_c 2<&1) > /tmp/c.cron.out
8 2 * * * root root (/backup/backup_d 2>&1) > /tmp/d.cron.out
40 8 * * * root root /bin/date > /tmp/date.cron.out

Thats my crontab, it executed the last command and created the file date.cron.out but it was empty, no data inside the file. I also tried it with the 2>&1 in that case no file was created at all. This is starting to piss me off cause I have no clue.
 
Old 09-09-2006, 07:10 AM   #9
isuck@linux
Member
 
Registered: Jun 2006
Distribution: messed up debian
Posts: 250

Original Poster
Rep: Reputation: 30
I don't really know cron that good, I fixed it using crontab -e and creating the crontab for root and putting the commands there instead of using the file /etc/crontab, for some reason now it works. Thanks anyways for all your help.
 
Old 09-11-2006, 03:05 AM   #10
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
You're welcome. Glad it works now.
 
  


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
problems setting the user in crontab p.gaic Linux - Software 1 07-15-2005 12:07 AM
crontab -e hoover93 Linux - Newbie 2 08-06-2004 05:05 PM
Setting up crontab SUSE Linux 8.2 byfaithalone Linux - Newbie 6 02-05-2004 04:42 PM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 01:35 PM
Setting global variables from a crontab job davee Programming 2 10-06-2003 08:05 AM


All times are GMT -5. The time now is 04:50 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