Crontab - URGENT pls


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Crontab - URGENT pls
# 1  
Old 09-12-2001
Crontab - URGENT pls

I put

30 2 * * * /usr/bin/tar cvf /dev/rct0 /u/csa/*

in my crontab file (SCO5) but I want to be absolutely sure that the backup job finishes successfully. I know that whenever cron cannot execute a command sends an e-mail to root with the error code and/or an explanation of the problem.

What I want is a way to display a message on screen so that I (or anyone else, in case I'm missing) can see it in the morning and check the backup status (completed successfully/not completed successfully).

Unfortunately, even though there is no mail about tar on root, I've the suspicion that the tar command is not executed. (To tell, I changed the time from 2:30, to 8:00 and nothing happened.)

Any help on that?
# 2  
Old 09-12-2001
I presume that you are using a shell script to run this back up.

What you could do is to do a test condition on the last command to see if was a success. zero being a success and anything else a fail.

For example

tar blah blah blah

if
[[ $? != 0 ]]

then
printf "There is a problem with the back up\n"
else
printf "The Backup Was Ok\n"
fi

I guess you could replace the printf with the command 'wall'
man wall for more details.

Hope this is of some help.
# 3  
Old 09-12-2001
Um, no... no scripts... just this command..

I was thinking something like tar .... > /dev/tty02 and get a confirmation message on the server.

On the other hand, is there any backup program for unix to propose? (Something like ARCServe or BackupEXEC for Windows and Novell)
# 4  
Old 09-12-2001
Depending on your user base (are all of you privelaged-type users, or do you have a lot of "regular" users on your system?), you could do a few things.

Number one, I'd (personally want to) place your commands into a script - just execute the script from cron. That way it'll be much easier to handle the jobs efficiently, and to include a little error handling as well. You could write anything in the script you wanted, including displaying a warning in the MOTD upon backup failure, mailing out to certain users, creating a log file, etc, etc, etc... Besides, if you run the script from cron, as opposed to the command itself, it will be much easier to update and change in the future.

Code:
#!/bin/sh
mv /etc/motd /etc/motd.bk
cat << EOF > /etc/motd
************************
There is a system backup in progress!
Please allow this to complete before
Modifying any of your files!
************************
EOF
wall << EOF
There is a system backup starting in one minute!
Please save all of your work now, and please
refrain from modifying any files until the back
is complete!
EOF
# Give them a few extra seconds
sleep 75 
echo "Start time: `date`" > /var/tmp/tar.log
tar cAuvf /dev/rmt/0m /home > /var/tmp/tar.log 2>&1 ; \
     chmod 600 /var/tmp/tar.log
mv /etc/motd.bk /etc/motd
wall << EOF
The backup of your home direcories is now complete!
Thank you for your patience.
EOF
echo "Stop time: `date`" >> /var/tmp/tar.log

Now, if you want that much extra debugging, at the top of the script, right under "#!/bin/sh", insert a line like this one:
set -x. If you do this, it also might be a good idea to redirect the entire script output to a different file:
30 2 * * * /path/to/my/fake/script.sh >> /var/tmp/tar-debug.log 2>&1

Please do not use the script above in a production environment, because I just made it up right now - instead hopefully you can grab some ideas out of it and build one that suits your needs - just keep in mind that the logs (both the tar -v output and the set -x output) will help you immensly!

Hope that helps!

Last edited by LivinFree; 09-12-2001 at 08:06 AM..
# 5  
Old 09-12-2001
Cron log

Did you check the cron log to see if the command was executed and the exit code? The cron log file is typically in /var/adm/cron/log
# 6  
Old 09-12-2001
Also, if a command in cron generates any
stderr output, normally this will be emailed
to the owner of the cron job. This mail can be
forwarded anywhere (provided your network allows).

But I also agree, a script is the BEST way to go.
# 7  
Old 09-12-2001
Quote:
Originally posted by pappous
On the other hand, is there any backup program for unix to propose? (Something like ARCServe or BackupEXEC for Windows and Novell)
Yes, there is.. I am running SCO R. 5 and I have SCO ARCserve 2.2 installed and running.. check

http://ca.com/upgrade/arcserve_unix_matrix.htm

for more info...

--e0
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Me Pls Its Urgent!!!!!!!!!!!!!!!!

Hi, These are the text file I have //input1.txt// cd dir1/dir2/pg1.txt cd dir3/dir4/pg2.txt cd dir88/dir5/pg4.txt cd dir7/dir6/pg5.txt cd dir8/dir9/pg7.txt And each text file has some text. Now I have to write a shell script which reads input1.txt and changes the directory as shown... (1 Reply)
Discussion started by: bhavanabahety
1 Replies

2. Shell Programming and Scripting

pls help me very urgent

will post again (1 Reply)
Discussion started by: revertback
1 Replies

3. Shell Programming and Scripting

Pls Help me.. soon. Very urgent

I have downloaded the Putty SSH configuration. I have entered my Host name as illinois.engr.sjsu.edu and i am trying to save that. But i am unable to save. Also i opened the session and entered my log in name But it says using keyboard interactive authentication.I am not able to get into $ ... (2 Replies)
Discussion started by: VamsiVasili
2 Replies

4. UNIX for Dummies Questions & Answers

URGENT :pls help

Following is d code snipet #!/bin/ksh retVal=`sqlplus -s user/passwd\@oracle_sid <<EOF SET SERVEROUTPUT ON SIZE 100000 DECLARE STATUS_VALUE VARCHAR2(1); BEGIN SELECT temp1 INTO STATUS_VALUE FROM sai; DBMS_OUTPUT.PUT_LINE(STATUS_VALUE); END; / exit; EOF` echo "Return Value... (2 Replies)
Discussion started by: sainathdeg
2 Replies

5. Shell Programming and Scripting

If not working...pls help:URGENT

Following is d code snipet #!/bin/ksh retVal=`sqlplus -s user/passwd\@oracle_sid <<EOF SET SERVEROUTPUT ON SIZE 100000 DECLARE STATUS_VALUE VARCHAR2(1); BEGIN SELECT temp1 INTO STATUS_VALUE FROM sai; DBMS_OUTPUT.PUT_LINE(STATUS_VALUE); END; / exit; EOF` echo "Return Value... (4 Replies)
Discussion started by: sainathdeg
4 Replies

6. Solaris

lex on solaris??? (urgent, pls!!!)

Hi everyone, I would like to know how to compile and run lex programs on solaris 10. the conventional way is $ lex <name.l> $ cc lex.yy.c -ll $ ./a.out but while trying to execute the 2nd command :i get a reference saying that the command is old or that main is not supported... Hence... (1 Reply)
Discussion started by: wrapster
1 Replies

7. Shell Programming and Scripting

Pls Help.. Really Urgent

Hi, I am creating a pipe in a directory $HOME/pipes. The pipename should be L${PROGNAME}. Whenever i embed these lines in shell script, i get an error mkfifo: No such file or directory. I am creating a pipe with the key word mkfifo $HOME/pipes/L${PROGNAME}. Please help me how to get... (5 Replies)
Discussion started by: raghavan.aero
5 Replies

8. UNIX for Dummies Questions & Answers

pls help on crontab

how to schedule shellscripts using cron tab (2 Replies)
Discussion started by: ss4u
2 Replies
Login or Register to Ask a Question