Hello,
I have got a script that I run to download a small file and check the internet speed while download is going on. The internet statistics are written to a log file. The script is called as test_script.
I want to run it through cron but have got some problems while it runs through cron.
Here is the script.
Code:
#!/bin/bash
####Set todays date####
set `date +%F%H%M`
####Create a file for todays date and time###
touch /ifstat/log.$1
####Write todays date in the file####
date +%F >> /ifstat/log.$1
date +%T >> /ifstat/log.$1
echo "==============================================================" >> /ifstat/log.$1
####Change the directory where the downloaded file is to be saved###
cd /downloads
####Remove all the files if there are any####
rm -rf *.*
####Start the download####
####Set the wget and ifstat processes####
set `ifstat -T >> /ifstat/log.$1 &`
set `wget http://xxxxxxxx.com/xx.exe`
####Keep loopig to find out if the download is complete and keep ifstat running ####till download is complete
while [ $3 ]
do $2
done
##echo "Download complete"
####Kill all the running ifstat processes####
pidof ifstat | xargs kill
####Write the end time of download to the file####
echo "==============================================================" >> /ifstat/log.$1
date +%F >> /ifstat/log.$1
date +%T >> /ifstat/log.$1
####Delete log files older than 7 days####
find /ifstat -mtime +7 -exec rm -rf {} \;
####Exit the script####
exit 0
This if run manually runs fine and gives proper output and kills the ifstat process. But if run in cron it fails to kill ifstat. Also ifstat keeps writing into file even after download is complete.
Any suggestions why this happens?
Edit:
Forgot to tell that I run it on RHEL4.