fauxCron updated.... again, June 24

Update June 24,2006
OK, I think I found a place to put the scripts where they will not be altered... You can look at newolduser.googlepages.com

Update June 23, 2006. I've noticed that the code in the fauxCron script is being altered by the blog page. The script will not work as it appears (some important if-statements are missing). Until I can fix this please feel free to email me for a copy of the fauxCron script. newolduser at gmail dot com

I've been poking around the fauxCron script some more. It works fine but I wanted an easier way to schedule weekly repeating tasks. The date +%a command will return the three character day of the week (with the first character capitalized).

With the new script you can still make your cronIN.txt entries as:
YYYYMMDDHHMM task to perform

but now you can also have entires like:
-----AaaHHMM task to perform

where Aaa is the abreviated day-of-the-week (Mon, Tue, Wed, Thu, Fri, Sat, Sun). Those setup to use non-English may want to test the date +%a command to see what it returns. It may return the day of the week in the local dialect. If that's the case then the script will still work if make you cronIN.txt entries using the local dialect.

Some of the other changes were:

1) remove all "back-tick command back-tick" entries and change them to "$(command)". The back-ticks are just too hard to read

2) the script will run every 60 seconds.

3) if a task is scheduled in the past the script will not execute it unless it's a weekly repeating type of task.

I've been running the updates for a while but I don't guarantee anything. Use it at your own risk and as far as I'm concerned it's all in the public domain so feel free to copy it..

I'm sorry but for some reason the indents are not showing up in the code listing. Please feel free to pretty things up on your own.

Good luck,
newOldUser at gmail dot com

updated fauxCron.sh script follows.

# fauxCron.sh for those without a cron...
# Required files:
# 1. cronIN.txt
# Last line contains "" in cols 1-5
# All other lines should have timestamp in col 1-12 YYYYMMDDHHMM
# or -----DOWHHMM (DOW = Day of Week, dashes are needed)
# 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
# changelog add at version 1.04
# v1.04 - added changelog
# commented out echo fauxCron checking...
# v2.00 - - added day of week checking using date +%a
# - no 'catch up' processing is done. If an event is missed it must be rescheduled
# - change all back-tick commands to $(command) for easier reading
while true
exec 3< cronIN.txt
thisRun=$(date +%Y%m%d%H%M)
thisRunDOW=$(date +%a%H%M)
#echo $thisRun $thisRunDOW "fauxCron checking..."
read taskTime taskCommand > cronLOG.txt
case $taskTime in
echo $taskTime $taskCommand >> cronOUT.txt;;
echo $taskTime $taskCommand >> cronOUT.txt
read taskTime taskCommand > cronOUT.txt
exec 3>&-
if [ $activityThisRun == "YES" ]; then
rm -f cronIN.txt
cat cronOUT.txt > cronIN.txt
rm -f cronOUT.txt
#sleep for 60 seconds if you set this to less then 60 then
#you run the risk of a weekly task (-----Mon1150) running twice
#in the same minute
sleep 60s
exit 0