View previous topic :: View next topic |
Author |
Message |
NotExcessive Apprentice

Joined: 10 May 2005 Posts: 235
|
Posted: Sun Jul 16, 2006 8:12 am Post subject: flexbackup not running under cron? [SOLVED] |
|
|
I've installed flexbackup and want to have it do automated backups under vixie-cron. Everything works when done manually, and I've added an entry to the crontab file to perform an incremental backup every hour.
This is what I have in /var/spool/cron/crontabs/root:
Code: | # DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXXt9Wqwc installed on Sat Jul 15 13:00:54 2006)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
0 2 * * * updatedb #Update db for slocate
@hourly flexbackup -set all -incremental #Incremental backup of system to tape
0 6 * * * emerge --sync |
Problem is, when the hour approaches, nothing happens. The entries get put into the log file, so it looks as if cron is issuing the command, but the tape drive sits idle.
This is what I see in /var/log/everything/current:
Code: | Jul 16 15:00:01 [cron] (root) CMD (rm -f /var/spool/cron/lastrun/cron.hourly)
Jul 16 15:00:01 [cron] (root) CMD (flexbackup -set all -incremental #Incremental backup of system to tape) |
I see this repeated every hour on the hour. If I look at it from Webmin -> System -> Scheduled Cron Jobs and hit the "run now" button, the tape backs up, as it should.
Can anyone tell me why the job's not running?
Last edited by NotExcessive on Tue Jul 18, 2006 2:27 pm; edited 2 times in total |
|
Back to top |
|
 |
frostschutz Advocate


Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Sun Jul 16, 2006 8:28 am Post subject: |
|
|
The # comment should probably not be on the same line as the cron job itself.
Instead of executing flexbackup directly, try wrapping it in a shell script and redirect all output into a >& /tmp/flexbackup.log file. Then you'll know wether the script gets executed at all (logfile exists or not), and what went wrong (according to output). |
|
Back to top |
|
 |
NotExcessive Apprentice

Joined: 10 May 2005 Posts: 235
|
Posted: Sun Jul 16, 2006 9:38 am Post subject: |
|
|
Ah. Creating a file /root/backinc with the following contents:
Code: | #!/bin/bash
flexbackup -set all -increment > flexbackup_output.log |
and then chmod+x backinc
resulted in the following being put into flexbackup_output.log when run from vixie-cron:
Code: | Errors:
mt not found in $PATH |
Yet I can cd into any directory and run /root/backinc from the command line without a problem - no errors at all. What's happening? The contents of /etc/crontab are Code: | # for vixie cron
#
# $Header: /var/cvsroot/gentoo-x86/sys-process/vixie-cron/files/crontab-3.0.1-r4,v 1.1 2005/03/04 23:59:48 ciaranm Exp $
#
#
# Global variables
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
# check scripts in cron.hourly, cron.daily, cron.weekly and cron.monthly
0 * * * * root rm -f /var/spool/cron/lastrun/cron.hourly
1 3 * * * root rm -f /var/spool/cron/lastrun/cron.daily
15 4 * * 6 root rm -f /var/spool/cron/lastrun/cron.weekly
30 5 1 * * root rm -f /var/spool/cron/lastrun/cron.monthly
*/10 * * * * root test -x /usr/sbin/run-crons && /usr/sbin/run-crons |
so $PATH includes /usr/sbin, which is where the mt utility lives.
Why is cron dropping the path to mt? |
|
Back to top |
|
 |
frostschutz Advocate


Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Sun Jul 16, 2006 11:50 am Post subject: |
|
|
I suggest you print the env variables out in the shellscript... to verify wether PATH is actually set correctly; also if it is, check the returnvalue of `which mt`. It should be found if it is in the path. |
|
Back to top |
|
 |
NotExcessive Apprentice

Joined: 10 May 2005 Posts: 235
|
Posted: Sun Jul 16, 2006 1:38 pm Post subject: |
|
|
Running env > showvars.txt and inspecting showvars.txt reveals
Code: | DOCUMENT_REALROOT=/usr/libexec/webmin
SHELL=/bin/sh
PATH_REALTRANSLATED=/usr/libexec/webmin/
USER=root
LD_LIBRARY_PATH=
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin
SERVER_REALROOT=/usr/libexec/webmin
PWD=/usr/libexec/webmin/cron/
REMOTE_ADDR=127.0.0.1
SHLVL=1
HOME=/root
LOGNAME=root
|
when run from the command line, BUT shows
Code: | SHELL=/bin/sh
USER=root
PATH=/usr/bin:/bin
PWD=/root
SHLVL=1
HOME=/root
LOGNAME=root
_=/usr/bin/env
|
when run from vixie-cron itself.
and which returns |
|
Back to top |
|
 |
frostschutz Advocate


Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Sun Jul 16, 2006 2:44 pm Post subject: |
|
|
Hmmm, so even though it is run as user root, the environment variables look like those of a normal user (no sbin in path).
I just tested this on my own machine; it's actually the same for me. No idea why these paths are not set. Maybe a search on the forums or in the bugtracker will reveal prior discussions to this.
Workaround: change PATH variable inside the shell script. |
|
Back to top |
|
 |
NotExcessive Apprentice

Joined: 10 May 2005 Posts: 235
|
Posted: Mon Jul 17, 2006 12:11 am Post subject: |
|
|
This seems to be the only thing to do. I've created a file /root/incremental_backup.sh:
Code: | #!/bin/bash
PATH=/usr/bin:/bin:/usr/sbin
flexbackup -set all -incremental |
And just put it into /var/spool/cron/crontabs/root:
Code: | @hourly /root/incremental_backup.sh |
And that's that. I just wonder, do I need to modify the file to output to /dev/null at all? flexbackup generates text output as to what it's done. It all works, just curious. |
|
Back to top |
|
 |
frostschutz Advocate


Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Mon Jul 17, 2006 7:00 am Post subject: |
|
|
Most cron will send you mails if the programs produce output (especially stderr output) to make you aware of errors. I'm not sure about vixie-cron though. |
|
Back to top |
|
 |
|