At extension scripts
From BononWiki
cat README
20100915 Stef Bon This readme is a description how to use at.generic.script.
INSTALLATION
The location I've used for my construction is:
/etc/atd
This location is not used by any other software, not even the at daemon self.
git clone git@gitorious.org:at-extension-scripts/at-extension-scripts.git mkdir /etc/atd cp <where you have got this script>/at.generic.script /etc/atd
INTRODUCTION
For a project I'm working on mount.md5key, I needed a "launch" manager. I've been looking to cron and fcron,
but both do not offer the functionality I need.
Basically I'm looking for a "launch" program, which is able to run program's on command, and offer some control over the command, run a list of commands, and queue management.
For example, the project mount.md5key uses udev (to detect hardware) and ConsoleKit (for session support), and both need a "launch" manager to make programs run. Why not directly? Plain and simple: both udev and ConsoleKit wait for the program/script to finish, which is not a good thing. Some hardware detection scripts take some time to finish, and all that time the udev daemon is waiting, unable to detect changes. The same with ConsoleKit,it also wait's for the program or script to finish, preventing the login (or logout) proces is waiting. This is not what you want!
Therefor I've created this script. You can use also use at directly, but you have less functionality.
Using a script to manage the launching looks trivial, but it offers various unique features like scripts (re) scheduling itself.
I've used it in combination with Udev, to run a command after a hardware change, and not let Udev wait for it to finish.
USAGE
General usage. The script uses some environment variables to run a command:
AT_COMMAND AT_COMMAND_LIST AT_WAIT_PERIOD AT_NEXT_COMMAND AT_QUEUED_POLICY AT_QUEUE AT_NEXT_COMMAND AT_PERIOD AT_TIME AT_STAMP_FILE
Run an already scheduled command now:
export AT_COMMAND="some script" at -f /etc/atd/at.generic.script NOW
will run the command "some script".
Schedule a command and later run it immediately, removing the scheduled job:
export AT_COMMAND="some script" at -f /etc/atd/at.generic.script NOW+10minutes
For example after 4 minutes, make it run:
export AT_QUEUED_POLICY="remove" at -f /etc/atd/at.generic.script NOW
This will remove the scheduled command and run it "now" instead.
Run a list of commands:
echo "script1" > /tmp/list.example echo "script2" >> /tmp/list.example echo "script3" >> /tmp/list.example export AT_COMMAND_LIST=/tmp/list.example at -f /etc/atd/at.generic.script NOW
Run a command and schedule another direct after that
A flexible way to make commands schedule themselves. It's getting very complicated, cause the at.generic.script is scheduling itself again, with other parameters.
export AT_COMMAND=script1 export AT_WAIT_PERIOD=2minutes export AT_NEXT_COMMAND=script2 at -f /etc/atd/at.generic.script NOW
This will run script1 NOW, and when it's ready, schedule script2 to be run 2 minutes later.
This is different from a list, this is more dynamic. You can make script1 for example set the AT_NEXT_COMMAND when it's finished. The at.generic.script detects this variable, and schedule it.
This functionality is not found in schedulers like fcron and cron. It's not possible there to make a command schedule itself.
This creates a big security issue here...