LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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-11-2009, 03:32 AM   #1
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,013

Rep: Reputation: 30
crontab didn't run


Seems my crontab didn't run lastnight as no backup file was created.
ANy ideas what's wrong?
Code:
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
00 23 * * * root /usr/bin/sarg
00 00 * * * root /etc/cron.daily/0logwatch
00 01 * * * root tar -cvvf backup-`date +%d%m%Y`.tar /etc /var/log /var/www /usr/lib/squid/ncsa_auth
#10 01 * * * root gzip backup-'date +%d%m%Y'.tar

@reboot  echo "Server has restarted "`hostname` | mail -s "System Restart" email@myemailadd.com
 
Old 08-11-2009, 03:46 AM   #2
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by qwertyjjj View Post
Seems my crontab didn't run lastnight as no backup file was created.
ANy ideas what's wrong?
Code:
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
00 23 * * * root /usr/bin/sarg
00 00 * * * root /etc/cron.daily/0logwatch
00 01 * * * root tar -cvvf backup-`date +%d%m%Y`.tar /etc /var/log /var/www /usr/lib/squid/ncsa_auth
#10 01 * * * root gzip backup-'date +%d%m%Y'.tar

@reboot  echo "Server has restarted "`hostname` | mail -s "System Restart" email@myemailadd.com
couple of things you can do.

try the command manually - make sure it works.
check the logs - /var/log/cron
best use full paths too, (/bin/tar) as cron has limited shell unless you tell it otherwise
redirect any errors to a log ( 2> /path/to/logfile)

better still and more cleaner, use roots crontab rather then /etc/crontab.
by that, i mean use crontab -e

Last edited by centosboy; 08-11-2009 at 03:48 AM.
 
Old 08-11-2009, 03:50 AM   #3
timvandijk039
Member
 
Registered: Jul 2009
Location: The Netherlands
Distribution: Debian/Ubuntu and RHEL/CentOS
Posts: 42

Rep: Reputation: 18
Is your cron daemon running?
Are there any log entries suggesting that there's some wrong?
 
Old 08-11-2009, 04:02 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
As a rule of thumb: *always* use full paths to programs and
files in crontabs.

Code:
00 01 * * * root /bin/tar -cvvf /path/to/backup-`/bin/date +%d%m%Y`.tar /etc /var/log /var/www /usr/lib/squid/ncsa_auth

Cheers,
Tink
 
Old 08-11-2009, 04:45 AM   #5
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,013

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Tinkster View Post
As a rule of thumb: *always* use full paths to programs and
files in crontabs.

Code:
00 01 * * * root /bin/tar -cvvf /path/to/backup-`/bin/date +%d%m%Y`.tar /etc /var/log /var/www /usr/lib/squid/ncsa_auth

Cheers,
Tink
Ok - I've changed that but this one didn't work either:
Code:
00 00 * * * root /etc/cron.daily/0logwatch
When I run it manually, I receive an email.
 
Old 08-11-2009, 06:46 AM   #6
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by qwertyjjj View Post
Ok - I've changed that but this one didn't work either:
Code:
00 00 * * * root /etc/cron.daily/0logwatch
When I run it manually, I receive an email.
does the cron log say it ran?

add
Code:
 2 >> /path/to/logfile at the end of the cron command
 
Old 08-11-2009, 07:30 AM   #7
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,013

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by centosboy View Post
does the cron log say it ran?

add
Code:
 2 >> /path/to/logfile at the end of the cron command
sorry, you mean right at the end of the cron script? What would that do?
 
Old 08-11-2009, 07:50 AM   #8
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by qwertyjjj View Post
sorry, you mean right at the end of the cron script? What would that do?
See "3.6.3 Appending Redirected Output" in bash reference manual
 
Old 08-11-2009, 08:16 AM   #9
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by qwertyjjj View Post
Ok - I've changed that but this one didn't work either:
Code:
00 00 * * * root /etc/cron.daily/0logwatch
When I run it manually, I receive an email.
If you installed from RPM then on RHEL / RHEL-ish this does not make sense as /usr/bin/run-parts will drive cronjobs in /etc/cron.{hourly,daily,weekly,monthly} from /etc/crontab. So Logwatch is already set to run without you mucking with crontab entries manually.

* By now I strongly suggest you pace things and read the Centos docs and Rute before proceding because you are running too much concurrent threads with too much simple, common questions that could be solved by reading the basic docs and using common sense. With all due respect.
 
Old 08-11-2009, 11:03 AM   #10
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,013

Original Poster
Rep: Reputation: 30
Like this:
Code:
# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
00 23 * * * root /usr/bin/sarg
2 >> /root/mylog.log
00 00 * * * root /etc/cron.daily/0logwatch
2 >> /root/mylog.log
00 01 * * * root /bin/tar -cvvf /root/backup-`/bin/date +%d%m%Y`.tar /etc /var/log /var/www /usr/lib/squid/ncsa_auth
2 >> /root/mylog.log
10 01 * * * root /bin/gzip /root/backup-'/bin/date +%d%m%Y'.tar
2 >> /root/mylog.log
 
Old 08-11-2009, 11:09 AM   #11
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Code:
00 00 * * * root /etc/cron.daily/0logwatch 2 >> /root/mylog.log
How do you execute the cronjob, in order to see if it works ?
 
Old 08-11-2009, 11:16 AM   #12
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,013

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by repo View Post
Code:
00 00 * * * root /etc/cron.daily/0logwatch 2 >> /root/mylog.log
How do you execute the cronjob, in order to see if it works ?
I just run this command at root:
/etc/cron.daily/0logwatch
 
Old 08-11-2009, 11:24 AM   #13
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
AFAIK, if there aren't any changes in the logfiles, since the previous run, no mail will be sent.
 
Old 08-13-2009, 03:19 AM   #14
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,013

Original Poster
Rep: Reputation: 30
I am getting the following errors in the crontab (sent to me by email) - any ideas what causes the EOF error?
Code:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=myemailaddress@howmanymoreerrors.com
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
00 21 * * * root /usr/bin/sarg
00 00 * * * root /etc/cron.daily/0logwatch
00 01 * * * root /bin/tar -cvvf /root/backup-`/bin/date +%d%m%Y`.tar /etc /var/log /var/www /usr/lib/squid/ncsa_auth
10 01 * * * root /bin/gzip /root/backup-`/bin/date +%d%m%Y`.tar
Code:
Cron <root@localhost> /bin/tar -cvvf /root/backup-`/bin/date +
/bin/bash: -c: line 0: unexpected EOF while looking for matching ``'
/bin/bash: -c: line 1: syntax error: unexpected end of file

Cron <root@localhost> /bin/gzip /root/backup-`/bin/date +
/bin/bash: -c: line 0: unexpected EOF while looking for matching ``'
/bin/bash: -c: line 1: syntax error: unexpected end of file
 
Old 08-13-2009, 03:24 AM   #15
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Please post the script which generates the errors
/root/backup
 
  


Reply



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
What does the run-parts mean in crontab? mTorbin Linux - Newbie 15 04-27-2012 03:53 PM
How to run this script in Crontab baig Linux - Newbie 2 11-30-2008 02:34 PM
Cannot get crontab to run uncle-c Linux - Newbie 4 02-12-2008 06:05 AM
How to run useradd from crontab? adrianphicks Linux - Enterprise 3 08-03-2004 12:00 AM
Can't run F-Prot with Crontab maxflex Slackware 7 07-31-2004 10:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:49 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
Open Source Consulting | Domain Registration