LinuxQuestions.org
Register a domain and help support LQ
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-13-2009, 04:25 AM   #16
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Original Poster
Rep: Reputation: 30

Quote:
Originally Posted by repo View Post
Please post the script which generates the errors
/root/backup
no, that's the filename.
When I run that exact command as listed in the cron code, it runs correctly, just not from the cron.
 
Old 08-13-2009, 04:47 AM   #17
centosboy
Senior Member
 
Registered: May 2009
Location: london
Distribution: centos5
Posts: 1,137

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by qwertyjjj View Post
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

cron isnt reading to the end of the command line for some reason.
tune this crontab up a bit.
do the tar and the compression in one sweep. drop verbose too - who needs that in a cronjob?

Code:
tar cfz /root/backup-`/bin/date +%d%m%Y`.tar.gz  /etc /var/log /var/www /usr/lib/squid/ncsa_auth

if you have to go the the next line, use \ at the end of the previous line.

i have had similar issues before, and solved it by removing newline character and continuing the command.

Or, just remove the whole line, and re - enter it.
 
Old 08-13-2009, 05:14 AM   #18
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Original Poster
Rep: Reputation: 30
Ok, so I have this now:
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 21 * * * root /usr/bin/sarg
00 00 * * * root /etc/cron.daily/0logwatch
00 01 * * * root /bin/tar cfz /root/backup-`/bin/date +%d%m%Y`.tar.gz  /etc /var/log /var/www /usr/lib/squid/ncsa_auth
Notably on the command line I get this warning:
/bin/tar: Removing leading `/' from member names


Where should I go to the next line?
Code:
/bin/tar cfz /root/backup-`/bin/date +%d%m%Y`.tar.gz  \
/etc /var/log /var/www /usr/lib/squid/ncsa_auth

Last edited by qwertyjjj; 08-13-2009 at 05:19 AM.
 
Old 08-13-2009, 06:12 AM   #19
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
There seem to be two problems here. Firstly the command truncation and secondly output from the command which is better avoided with cron.

Both could be solved by putting the command in a script called from the crontab and ensuring all output goes to a log file, not to stdout or stderr
Code:
#!/bin/bash
/bin/tar cfz /root/backup-`/bin/date +%d%m%Y`.tar.gz  /etc /var/log /var/www /usr/lib/squid/ncsa_auth > my_logfile 2>&1
 
Old 08-13-2009, 10:11 AM   #20
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by catkin View Post
There seem to be two problems here. Firstly the command truncation and secondly output from the command which is better avoided with cron.

Both could be solved by putting the command in a script called from the crontab and ensuring all output goes to a log file, not to stdout or stderr
Code:
#!/bin/bash
/bin/tar cfz /root/backup-`/bin/date +%d%m%Y`.tar.gz  /etc /var/log /var/www /usr/lib/squid/ncsa_auth > my_logfile 2>&1
ok, I've created a script and made it executable.
The cron now reads:
Code:
00 01 * * * root /root/dailybackup.sh
That correct?
Does the logfile get rewritten each time because I have run it a few times now using either
./dailybackup.sh or
/root/dailybackup.sh

and the logfile remains with 1 line in each time...a warning about removing leading /
 
Old 08-13-2009, 05:59 PM   #21
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Yes, it gets overwritten. If you want to keep a history change the single '>' to '>>'
Code:
/bin/tar cfz /root/backup-`/bin/date +%d%m%Y`.tar.gz  /etc /var/log /var/www /usr/lib/squid/ncsa_auth >> my_logfile 2>&1
 
Old 08-13-2009, 07:30 PM   #22
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
You could use the date command to generate timestamps for including in the log file name.
 
Old 08-14-2009, 03:24 AM   #23
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 created a script and made it executable.
The cron now reads:
Code:
00 01 * * * root /root/dailybackup.sh
That correct?
Does the logfile get rewritten each time because I have run it a few times now using either
./dailybackup.sh or
/root/dailybackup.sh

and the logfile remains with 1 line in each time...a warning about removing leading /

i wouldnt worry about this warning
 
Old 08-14-2009, 06:14 AM   #24
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by centosboy View Post
i wouldnt worry about this warning
Ok, next
I am receiving logwatch emails twice a day from my cron instead of just once.
Is logwatch run by the cron.daily as well as my own code below it?
Code:
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 /root/dailybackup.sh
*/10 * * * * root /root/update_demo_users.sh
 
Old 08-14-2009, 06:40 AM   #25
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,527

Rep: Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898Reputation: 898
Seems to me you run it at "00 00" and "02 4"
Look at the time from the mail.
 
Old 08-14-2009, 06:50 AM   #26
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by repo View Post
Seems to me you run it at "00 00" and "02 4"
Look at the time from the mail.
Yes but is there something on the cron config that tells it to run as part of cron.daily.
In my command at 00 00, I specifically state logwatch
 
Old 08-14-2009, 06:51 AM   #27
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, next
I am receiving logwatch emails twice a day from my cron instead of just once.
Is logwatch run by the cron.daily as well as my own code below it?
Code:
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 /root/dailybackup.sh
*/10 * * * * root /root/update_demo_users.sh
Code:
ls -la /etc/cron.daily
any script in /etc/cron.daily runs as so - 04:02hrs daily

Code:
02 4 * * * root run-parts /etc/cron.daily

Last edited by centosboy; 08-14-2009 at 06:54 AM.
 
Old 08-14-2009, 06:53 AM   #28
qwertyjjj
Senior Member
 
Registered: Jul 2009
Location: UK
Distribution: Cent OS5 with Plesk
Posts: 1,012

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by centosboy View Post
Code:
ls -la /etc/cron.daily
Aha
Code:
total 100
drwxr-xr-x  2 root root  4096 Aug  9 21:20 .
drwxr-xr-x 91 root root 12288 Aug 14 11:15 ..
-rwxr-xr-x  1 root root   133 Jan  9  2007 00webalizer
-rwxr-xr-x  1 root root   379 Mar 28  2007 0anacron
lrwxrwxrwx  1 root root    39 Aug  6 17:08 0logwatch -> /usr/share/logwatch/scripts/logwatch.pl
-rwxr-xr-x  1 root root   442 Nov 30  2008 apt
-rwxr-xr-x  1 root root  1042 May 24  2008 certwatch
-rwxr-xr-x  1 root root   118 Jun  3 21:44 cups
-rwxr-xr-x  1 root root   180 Feb 26 22:52 logrotate
-rwxr-xr-x  1 root root   418 Jan  6  2007 makewhatis.cron
-rwxr-xr-x  1 root root   137 Feb 26 23:28 mlocate.cron
-rwxr-xr-x  1 root root  2181 Jun 21  2006 prelink
-rwxr-xr-x  1 root root   296 Jan 21  2009 rpm
-rwxr-xr-x  1 root root   166 Sep 12  2007 sarg
-rwxr-xr-x  1 root root   328 Feb 26 10:36 tmpwatch
-rwxr-xr-x  1 root root    26 Dec 12  2007 yum-updates
So, I don't even need the srag code in there.
Is cron.daily a separate file containing what to run? when it lists sarg in here it doesn't have a path to the sarg directory yet it does for logwatch's perl script?
 
Old 08-14-2009, 08:04 AM   #29
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
Originally Posted by qwertyjjj View Post
Is cron.daily a separate file containing what to run?
Reread post #9?


Quote:
Originally Posted by qwertyjjj View Post
when it lists sarg in here it doesn't have a path to the sarg directory yet it does for logwatch's perl script?
If you would have read your Centos docs and Rute (as I offered before) you'd known that. If you don't know what a file is just run 'file' on it:
Code:
]$ file /etc/cron.daily/0logwatch 
/etc/cron.daily/0logwatch: symbolic link to `/usr/share/logwatch/scripts/logwatch.pl'
 
  


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


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