LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-18-2006, 10:30 PM   #1
subcon
LQ Newbie
 
Registered: Oct 2005
Posts: 12

Rep: Reputation: 0
Question Issue with dump / cron


Greetings.

I currently am running a server which has recently been augmented with a tape backup system (model info below). I have written a very simple bash script to run backups (scripts contents below), and running this from the command line yields a successful backup. I have tested this manually many times, and all disaster-recovery tests have been 100% successful.

So I have added this to my crontab (shown below), which has two other jobs scheduled that run perfectly. For the life of me, I CANNOT get my backup script to run automatically via cron (which I have previously mentioned runs PERFECTLY from the command line).

I have checked /var/log/cron and it indeed says the job has run. However, the job clearly does NOT run, because 'dump' never appears as a running process in 'top' or 'ps'.

Permissions are fine (the other two jobs have identical permissions, execute-bits and ownership). Root owns the files, and it is root's crontab which executes these jobs. Running the command with 'at' works fine as well, I just prefer cron.

Here is my current system:

Tape Backup Unit:

Sony SDX-260V IDE
Using 21/50 GB tapes

'/root/root.crontab' contents:

00 21 * * * /SCRIPTS/dump_current_mail.sh <--- runs GREAT
05 22 * * * /SCRIPTS/mail_transfer.sh <--- also runs GREAT
00 23 * * * /SCRIPTS/backup.sh <--- WILL NOT RUN WITH CRON

Crontab is activated using 'crontab root.crontab' at the bash prompt as root. This is the way I have always done it, and ALL the other machines I run use this method and I do not have this problem with any of them.

'/SCRIPTS/backup.sh' contents:

mt -f /dev/tape eod <--- Go to end of data on this tape
dump -f /dev/tape /MASTER/Data/ <--- dump this dir to this tape drive
dump -f /dev/tape /MASTER/MAIL <--- dump this dir to this tape drive

For those of you who know 'dump', this is incredibly simple (I am no expert with 'dump'). These commands work perfectly as individual commands, AND they work perfectly when this script is executed MANUALLY.

I am out of ideas. Any help would be appreciated, as I am having to do these backups manually every night =)

Thanks

subcon
 
Old 05-18-2006, 11:01 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
One test you could try is to run the script manually but in the background.
If it doesn't run, you may need to redirect the output to /dev/null, or take stdin from /dev/zero.
You could try redirecting the output to /dev/null in the script.
 
Old 05-18-2006, 11:22 PM   #3
subcon
LQ Newbie
 
Registered: Oct 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Question

Running the script with & at the end ran, however doing so in crontab yielded no result. I even made a separate script, called execute_backup.sh with the following contents:

/SCRIPTS/backup.sh 2&1> /dev/null
 
Old 05-18-2006, 11:56 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Try adding 2&>/dev/null to the cron command itself
00 23 * * * /SCRIPTS/backup.sh 2&>/dev/null
 
Old 05-19-2006, 12:11 AM   #5
subcon
LQ Newbie
 
Registered: Oct 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Question

=( Still no luck. 'top' shows no evidence of dump being run. This is so weird ...
 
Old 05-19-2006, 01:10 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
iirc, the PATH used by cron is very minimalist ie it's poss that the tape cmds are not in the avail path. Try
echo $PATH
at the top of the shell script.
A way to debug it (shell file) is to say
set -xv
as the 2nd line (ie 1st after shebang line) of the shell script.
 
Old 05-19-2006, 01:19 AM   #7
subcon
LQ Newbie
 
Registered: Oct 2005
Posts: 12

Original Poster
Rep: Reputation: 0
I'll try that in the morning, I'm about to pass out. Thanks guys ....
 
Old 05-19-2006, 01:40 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Nice catch, subcon!

Instead of redirecting the output, perhaps you should redirect it to a file. Both the stdout and stderr streams. At least until you have it working.
This may provide information on what is going wrong.

I took a look at my /etc/crontab file.
Code:
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/15 * * * *   root  test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1
If "dump" isn't in the path, you can add the path in a PATH= command.

Last edited by jschiwal; 05-19-2006 at 02:25 AM.
 
Old 05-25-2006, 12:25 AM   #9
subcon
LQ Newbie
 
Registered: Oct 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Thank You

IT WORKED.

The end result (backup.sh):

SHELL=/bin/bash
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
mt -f /dev/tape eod
echo BEFORE DUMP: `date +%A-%Y.%m.%d` `mt tell` >> /root/backup_status.log
dump -f /dev/tape /MASTER/Data/
dump -f /dev/tape /MASTER/MAIL/
echo AFTER DUMP: `date +%A-%Y.%m.%d` `mt tell` >> /root/backup_status.log

THANK YOU THANK YOU

subcon
 
  


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
"DUMP", cron, and multiple tapes ghight Linux - Software 2 03-06-2007 03:59 AM
cron issue abdul_zu Linux - Newbie 8 07-31-2005 11:39 PM
rmmod and cron issue? Manuel-H Linux - Software 1 10-23-2004 07:05 AM
How to forcely dump the history of user commands to the admin dump file. mcp_achindra Linux - Security 1 03-19-2004 12:04 PM
Help with cron dump job odious1 Linux - General 2 01-13-2004 02:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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