Quote (_pathos @ Mar. 20 2006,01:30) |
could this be done with a bash script? |
Code Sample |
#!/bin/bash while [ 1 ] do sleep 5m date ## replace this with your command(s) done |
Code Sample |
200603240300 echo Yikes 200603240230 doBackupStuff.sh 200612312359 echo happy new year <end> |
Code Sample |
#!/bin/bash version="0.01" # fauxCron.sh for those without a cron... # # Required files: # # 1. cronIN.txt # # Last line contains "<end>" in cols 1-5 # # All other lines should have timestamp in col 1-12 # blank in col 13 # command to be executed starting in col 14 # # # 2. cronLOG.txt # # As commands are executed they are copied to this file with the # timestamp when they were executed put in front. # # # Temporary file: # # 1. cronOUT.txt - temporary file that becomes cronIN.txt # while true do exec 3< cronIN.txt thisRun=`date +%Y%m%d%H%M` echo $thisRun "fauxCron checking..." read taskTime lastRun <&3 while [ $taskTime != "<end>" ] do read taskTime taskCommand <&3 if [ $taskTime != "<end>" ]; then if [$taskTime -le $thisRun ]; then nice $taskCommand & echo $thisRun $taskTime $taskCommand >> cronLOG.txt else echo $taskTime $taskCommand >> cronOUT.txt fi fi done echo "<end>" >> cronOUT.txt exec 3>&- rm -f cronIN.txt cat cronOUT.txt > cronIN.txt rm -f cronOUT.txt sleep 5m done exit 0 |
Code Sample |
#!/bin/bash # an example of a timed action OLD_MD5=`md5sum myfile` while true do sleep 5m # sleep for 5 minutes # could be 5s or 12h, # whatever you need if ! [ "$OLD_MD5" = "`md5sum myfile`" ] then # if the md5sum on the file has changed, back it up OLD_MD5=`md5sum myfile` # save the new sum echo $OLD_MD5 # display the fact we are changing # do backup stuff here fi done |
Code Sample |
#!/bin/bash version="0.02" # fauxCron.sh for those without a cron... # # Required files: # # 1. cronIN.txt # # Last line contains "<end>" in cols 1-5 # # All other lines should have timestamp in col 1-12 # blank in col 13 # command to be executed starting in col 14 # # # 2. cronLOG.txt # # As commands are executed they are copied to this file with the # timestamp when they were executed put in front. # # # Temporary file: # # 1. cronOUT.txt - temporary file that becomes cronIN.txt # while true do exec 3< cronIN.txt thisRun=`date +%Y%m%d%H%M` echo $thisRun "fauxCron checking..." read taskTime taskCommand <&3 while [ $taskTime != "<end>" ] do if [ $taskTime -le $thisRun ]; then nice $taskCommand & echo $thisRun $taskTime $taskCommand >> cronLOG.txt else echo $taskTime $taskCommand >> cronOUT.txt fi read taskTime taskCommand <&3 done echo "<end>" >> cronOUT.txt exec 3>&- rm -f cronIN.txt cat cronOUT.txt > cronIN.txt rm -f cronOUT.txt sleep 5m done exit 0 |