Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running at job after every five minutes

Status
Not open for further replies.

newbreak

Programmer
Jun 30, 2001
1
US
Hi All,

I have several zip files(under /export/home/ftp/siac/*.zip) on one machine called arbitrage and my goal is to transfer this file from arbitrage to lenbkx0001 (under lenbkx0001:/nb_apps/dev/ashish/proj/datafiles) which is other machine. And lenbkx0001 I have perl script which reads this file and do some task as a background process and if everything is ok then do all process after five minutes again.

I wrote two small .ksh shell script one for file transfer from arbitrage machine to lenbkx0001 and this script is on arbitrage machine and other .ksh shell script is calling perl program and this script is on lenbkx0001 machine. Both scripts are very straight forward. But some how these scripts are not working. And main idea is that it should run after every 5 minutes so I used at UNIX command. I put my both ksh script here:

Script 1: Arbitrage machine ksh shell script:
#! /usr/bin/ksh -f

# if rcp success then remove the zip file
rcp /export/home/ftp/siac/*.zip lenbkx0001:/nb_apps/dev/ashish/proj/datafiles
rm -f /export/home/ftp/siac/*.zip 2>> /var/tmp/runRcpLog 1>&2
at -k -f $HOME/runRcp.ksh now + 5minutes 2>> /var/tmp/runRcpLog 1>&2

script 2: on lenbkx0001 machine

#! /usr/bin/ksh -f


cd $BASE_DIR/proj/datafiles
filelist=`ls | grep zip`
#ls -la
#`pwd`
#echo ${filelist}

for filename in $filelist
do
if [ ! -a $BASE_DIR/proj/datafiles/${filename} ]
then
echo "there is no zip file exist." 2>> /var/tmp/runCronJobLog 1>&2
at -k -f $BASE_DIR/proj/runCronJob.ksh now + 5minutes 2>> /var/tmp/runCronJobLog 1>&2
else
nohup perl $BASE_DIR/proj/apps/testprod.pl 2>> /var/tmp/runCronJobLog 1>&2
mv -f $BASE_DIR/proj/datafiles/${filename} /data/factor-files
at -k -f $BASE_DIR/proj/runCronJob.ksh now + 5minutes 2>> /var/tmp/runCronJobLog 1>&2
fi
done

Please e-mail me on ashah4@hotmail.com

Thanks,

A
 
Hi,

you did not tell us, what is going wrong with your scripts, do they start at all, or do they crash with an error, or...?

some hints:

for the at-commad:
USAGE
The format of the at command line shown here is guaranteed
only for the "C" locale. Other locales are not supported for
midnight, noon, now, mon, abmon, day, abday, today, tomor-
row, minutes, hours, days, weeks, months, years, and next.

you should consider using "cron" instead of "at"

for script1:
the rm-command does remove any zip-file in the given directory, regardless wether the previous rcp succeeded successfully or not.
and by the use of "-f" it won't complain if it can not find any file to remove, so redirecting STDERR to a file is useless.

for script2:
why use "grep" for generating the filelist?
filelist=$( ls *.zip )

what's the value of BASE_DIR? (not set in script..)
include "set -x" for debugging.

the use of "echo 'something' 2>>file 1>&2" may impress your sister,
why not use "echo 'this' >>file"?

ciao,
mbr
 
it might be easier to use cron to run a job every five minutes - have you tried that? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top