newOldUser
Group: Members
Posts: 241
Joined: Oct. 2004 |
|
Posted: Mar. 24 2006,17:22 |
|
Well.... in the light of day I see a problem with my version 0.01... It looks like it will miss the first entry in the cronIN.txt file. I've moved the reads around a little and came up with version 0.02
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
|
clacker, having it run at a certain time got me thinking about another project I want to do. I've been playing around with having mplayer record internet radio broadcasts. It would be nice to be able to have my server start recording at a certain time and day. When I get it working I'll post how it's done.
The other nice thing is that you can modify cronIN.txt with additional tasks and not have to change the script. Now if someone would build a nice Flua gui frontend to populate the cronIN.txt file.... maybe with a "repeat" slider that would create x number of entries. One for each day, week, month.... on a given task.
-------------- ======== Note ========= The DSL Forum Search default is 'OR' If you search for "cat dog" you will get all "cat" posts and all "dog" posts. If you search for "cat AND dog" you will only find results that contain BOTH "cat" and "dog" Add '*' for wildcards, " cat* and dog* "
|