*nix Thread, crontab not working in Technical; Hi, to start here's my crontab on my Ubuntu install:
Code:
sudo crontab -e
Which gives me:
Code:
# m ...
-
16th March 2009, 02:18 PM #1 crontab not working
Hi, to start here's my crontab on my Ubuntu install:
Which gives me:
Code:
# m h dom mon dow command
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
00 08-18/1 * * * sarg-reports today
00 00 * * * sarg-reports daily
00 08-18/1 * * * /var/backupscripts/squid.sh
The first two jobs appear to work fine - I mean I can view the logs of my squid server. The 3rd line (squid.sh) does not work however. squid.sh is a backup script that copies certain files to a SMB share. It works fine is I manually enter sudo /var/backupscripts/squid.sh so why won't it work in the crontab?
The contents of the backup script are as follows:
Code:
#!/bin/sh
DIRS="/var/www"
BACKUP=/var/backupscripts/backups/backup.$$
NOW=$(date +"%d-%m-%Y")
INCFILE="/root/tar-inc-backup.dat"
DAY=$(date +"%a")
### MySQL Setup ###
MUSER="xxx"
MPASS="xxx"
MHOST="localhost"
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
GZIP="$(which gzip)"
SMBCLIENT="$(which smbclient)"
### Start Backup for file system ###
[ ! -d $BACKUP ] && mkdir -p $BACKUP || :
SMBD="xxx"
FILE="fs-full-$NOW.tar.gz"
tar -zcvf $BACKUP/$FILE $DIRS
### Start MySQL Backup ###
# Get all databases name
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
for db in $DBS
do
FILE=$BACKUP/mysql-$db.$NOW-$(date +"%T").gz
$MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done
tar -zcvf $DAY.tgz $BACKUP
### Dump backup using SMB ###
smbclient //xxx.xxx.xxx.xxx/xxx -U xxx%xxx -c "put $DAY.tgz"
rm -rf $BACKUP
rm -rf $DAY.tgz
I'm not sure what to do to find out why it is failing so any advice in diagnosing this would be appreciated
-
-
IDG Tech News
-
16th March 2009, 02:22 PM #2 what crons logfile say? Also, you should be getting email about the failing job, what does that report?
-
-
16th March 2009, 02:32 PM #3 
Originally Posted by
Geoff
what crons logfile say? Also, you should be getting email about the failing job, what does that report?
Sorry for being a n00b and asking a stupid question but how do I check the emails?
-
-
17th March 2009, 10:39 AM #4
- Rep Power
- 9
Email from crontab goes to the user who is running that job - if it's the system crontab that's root. You might want to setup a redirect so you get the mail for root, easy to do edit /etc/aliases and find the root: line, eg:
Code:
jim@eros:~$ cat /etc/aliases | grep root:
root: serverlogs@wildern.hants.sch.uk
Then get your mailer to recheck the aliases (only needed if you're using sendmail):
To check the mail on the command line, switch to the user who is getting the mail and run or install something abit more friendly like mutt to read it.
Lastly, is your backup script set as executable? Check that and also optionally add a shell in which to run the script (your cron may not use bash):
Code:
00 08-18/1 * * * /bin/sh /var/backupscripts/squid.sh
-
Thanks to james_yale from:
Hightower (17th March 2009)
-
17th March 2009, 11:24 AM #5 
Originally Posted by
james_yale
add a shell in which to run the script (your cron may not use bash):
Code:
00 08-18/1 * * * /bin/sh /var/backupscripts/squid.sh
I added that line and it seems to have done the trick (well it backed up automatically at 10 for the first time).
Thank you! 
P.S. If you get chance could you explain why I needed that line, so I know for future.
-
SHARE:
Similar Threads
-
By browolf in forum Networks
Replies: 13
Last Post: 15th December 2008, 02:50 PM
-
By localzuk in forum General Chat
Replies: 4
Last Post: 10th September 2008, 06:13 PM
-
By Scotmk in forum General Chat
Replies: 2
Last Post: 23rd July 2008, 12:04 PM
-
By Jackd in forum EduGeek.net Site Problems
Replies: 4
Last Post: 21st January 2008, 10:49 AM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules