Next Previous Contents

5. The Solution

5.1 Briefly

5.2 In Detail

AT

Use the 'at' command to submit your usual mondoarchive command. My mondoarchive command is:

mondoarchive -D -Ow 10 -S /home/mondo/ -T /home/mondo/ -g \
-E "\"/home/cdaly/GIS/W2K /home/mondo/\"" -9

To submit the mondoarchive command with 'at' do:

at now + 5 min 
mondoarchive -D -Ow 10 -S /home/mondo/ -T /home/mondo/ -g \
-E "\"/home/cdaly/GIS/W2K /home/mondo/\"" -9 
<CTRL>-d

This generates a script in /var/spool/at/ which sets up your environment and runs your command. Grab this script to become your cron job.

Grab the 'at' script

Make a copy of the script generated by the 'at' command to use as the basis for your cron job.

grep mondo /var/spool/at/* 
cp /var/spool/at/<file-from-grep> /root/mondo-cronscript

You'll need to edit this.

Edit mondo-cronscript

To use screen, you'll need to edit the cronscript and add the screen command. My mondo-cronscript looks like:

#!/bin/sh 
# atrun uid=0 gid=0 
# mail    cdaly 0 umask 22 
PWD=/root; export PWD 
XAUTHORITY=/root/.xauthyOrD4f; export XAUTHORITY 
HOSTNAME=bofh.irmet.ie; export HOSTNAME 
PVM_RSH=/usr/bin/rsh; export PVM_RSH 
QTDIR=/usr/lib/qt-2.3.1; export QTDIR 
LESSOPEN=\|/usr/bin/lesspipe.sh\ %s; export LESSOPEN 
XPVM_ROOT=/usr/share/pvm3/xpvm; export XPVM_ROOT 
KDEDIR=/usr; export KDEDIR 
USER=root; export USER 
LS_COLORS=no=00:fi=00:di=01\;34:ln=01\;36:pi=40\;33:so=01\;35:bd=40\;33\;01:cd=40\;33\;01:or=01\;05\;37\;41:mi=01\;05\;37\;41:ex=01\;32:\*.cmd=01\;32:\*.exe=01\;32:\*.com=01\;32:\*.btm=01\;32:\*.bat=01\;32:\*.sh=01\;32:\*.csh=01\;32:\*.tar=01\;31:\*.tgz=01\;31:\*.arj=01\;31:\*.taz=01\;31:\*.lzh=01\;31:\*.zip=01\;31:\*.z=01\;31:\*.Z=01\;31:\*.gz=01\;31:\*.bz2=01\;31:\*.bz=01\;31:\*.tz=01\;31:\*.rpm=01\;31:\*.cpio=01\;31:\*.jpg=01\;35:\*.gif=01\;35:\*.bmp=01\;35:\*.xbm=01\;35:\*.xpm=01\;35:\*.png=01\;35:\*.tif=01\;35:; export LS_COLORS 
MACHTYPE=i386-redhat-linux-gnu; export MACHTYPE 
MAIL=/var/spool/mail/root; export MAIL 
INPUTRC=/etc/inputrc; export INPUTRC 
BASH_ENV=/root/.bashrc; export BASH_ENV 
LANG=en_US; export LANG 
LOGNAME=root; export LOGNAME 
SHLVL=1; export SHLVL 
II_SYSTEM=/usr/local/ingres; export II_SYSTEM
USERNAME=root; export USERNAME 
HOSTTYPE=i386; export HOSTTYPE 
OSTYPE=linux-gnu; export OSTYPE 
HISTSIZE=1000; export HISTSIZE 
LAMHELPFILE=/etc/lam/lam-helpfile; export LAMHELPFILE 
PVM_ROOT=/usr/share/pvm3; export PVM_ROOT 
HOME=/root; export HOME 
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass; 
export SSH_ASKPASS 
PATH=/usr/local/ingres/ingres/bin:/usr/local/ingres/ingres/utility:/usr/kerberos/sbin:/usr/kerberos/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin/X11:/usr/X11R6/bin:/root/bin; export PATH 
cd /root || {
echo 'Execution directory inaccessible' >&2     
exit 1 
} 
screen -m -d mondoarchive -D -Ow 10 -S /home/mondo/ -T \
/home/mondo/ -g -E "\"/home/cdaly/GIS/W2K /home/mondo/\"" -9
#done 

The crucial line is this one:

screen -m -d mondoarchive -D -Ow 10 -S /home/mondo/ -T \
/home/mondo/ -g -E "\"/home/cdaly/GIS/W2K /home/mondo/\"" -9

This uses 'screen -m -d' to

-m -d Start screen in "detached" mode. This creates a new session but doesn't attach to it. This is useful for system startup scripts. (From 'man screen')

When screen starts, it will be in the background and "detached".

Run the thing with cron

To get the whole thing running, do:

crontab -e 

and add the following lines:

# run mondoarchive at 23:59 weekdays 
59 23 * * 1-5 /root/mondo-cronscript

Your mondoarchive job will run at 23:59 monday-friday.

DON'T FORGET TO CHANGE TAPES!

Getting at it...

Once your cron job is running regularly, you'll want to get to it to change tapes and check status etc.

screen -r 

attaches to the running screen where you can change CDs etc

<CTRL>-a d 

detaches the running screen again.

Caveat

The script generated by 'at' is unique to the user/machine combination. You MUST regenerate it on each machine where it will be used. Using the one above will NOT work for you. MAKE YOUR OWN!


Next Previous Contents 1