Hello, can someone suggest an alternative to "at" for scheduled script execution? I currently use at to schedule recordings with my tv-card, but I find it lacking in a few ways. One thing that would be nice if the scheduler could execute a script at one time, kill it off at another, and prevent other jobs from being scheduled in the time in between. This because access to the tv device is only allowed by one process at once. Also, I think the output is lacking. Here is how I use at today: The current output of atq: 44 2006-10-01 17:00 a claes 32 2006-09-30 23:25 a claes 34 2006-09-27 22:00 a claes 45 2006-10-08 17:00 a claes 46 2006-09-27 22:00 a claes 47 2006-10-04 22:00 a claes 42 2006-09-30 21:00 a claes Each of these jobs correspond to a certain recording, but the listing does not reveal which one, and at what time it ends. To find that I have to enter at -c jobname, which will print a lot of garbage with the interesting stuff at the bottom: at -c 48 #LOTS of env stuff... G_BROKEN_FILENAMES=1; export G_BROKEN_FILENAMES JAVA_ROOT=/usr/lib/jvm/java; export JAVA_ROOT COLORTERM=1; export COLORTERM mc=\(\)\ {\ \ .\ /usr/share/mc/bin/mc-wrapper.sh" "}; export mc cd /home/claes || { echo 'Execution directory inaccessible' >&2 exit 1 } rectv 6 1h simpsons The bottom line is a call to my recording script with arguments for channel, duration and name. I would have liked it if I could give the scheduler the duration and name and have it present it in the listing. Or at least, if the scheduler would take a name for argument so i could name the jobs and see them in the listing. Note that I prefer a simple, command-line-driven program since this will run on a headless server. Thanks, Claes
On 9/26/06, Claes at work
Hello,
can someone suggest an alternative to "at" for scheduled script execution? I currently use at to schedule recordings with my tv-card, but I find it lacking in a few ways.
Have you had a look at cron? man crontab A crontab allows you to specify when a job should be started and you can see your entries with crontab -l (crontab -e to edit the crontab) I normally write scritps for different jobs and give the script a descriptive name. THen I schedule it in my crontab. You can also put comments in the crontab (similar syntax as shell script). If I want to start a job and prevent others from running while that one is running, then I write the script to touch a lock file somewhere . Then, the other scripts will check if the lock file exist and will immediately exit. When the script is done, it deletes the lock file and thus the next script will start HTH -- Andre Truter | Software Consultant | Registered Linux user #185282 Jabber: andre.truter@gmail.com | http://www.trusoft.co.za ~ A dinosaur is a salamander designed to Mil Spec ~
On Tuesday 26 September 2006 14:13, Andre Truter wrote:
On 9/26/06, Claes at work
wrote: Hello,
can someone suggest an alternative to "at" for scheduled script execution? I currently use at to schedule recordings with my tv-card, but I find it lacking in a few ways.
Have you had a look at cron?
man crontab
Gui interface also available: kcron under kde -- _____________________________________ John Andersen
can someone suggest an alternative to "at" for scheduled script execution? I currently use at to schedule recordings with my tv-card, but I find it lacking in a few ways.
Have you had a look at cron?
The 'problem' with cron is that it was designed for periodic tasks, not one-time tasks. Jan Engelhardt --
On Wednesday 27 September 2006 08:07, Jan Engelhardt wrote:
The 'problem' with cron is that it was designed for periodic tasks, not one-time tasks.
It can be done, though: have your cron job install a separate crontab file, replacing the existing one. At the end of your job (or at the beginning), do: crontab my_new_crontab_file You can keep several different crontab laying around and load them at will. Using 'crontab -e' you can edit the current crontab, and using 'crontab -l' you can dump the current crontab to stdout: crontab -l > my_old_crontab_file To address your earlier post about at: a) 'at' has no built-in support for blocking other tasks. As another user suggested, you'll need to build wrapper scripts and use a lock file. This is not difficult to do in bash. b) the atq output doesn't show the commands you want to run, right - doing so could be a potential security hole, as someone might be able to see, at a glance, what you've got planned. c) The output of the at scripts shows a "lot of junk", but that junk is GOOD junk. It ensures that your at job runs with the environment variables which were set when you set up the job. If this wasn't done, many at jobs would fail mysteriously when vars, like CVS_SSH and HOSTNAME, aren't set. cron has this problem, for example: it's often necessary to source your ~/.profile file at the start of the job if you want to use environment vars which are "system-standard". i don't know of an alternative to 'at', and would recommend (a) for what you're trying to do - lock certain tasks while others are running. -- ----- stephan@s11n.net http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts
On 9/27/06, stephan beal
On Wednesday 27 September 2006 08:07, Jan Engelhardt wrote:
The 'problem' with cron is that it was designed for periodic tasks, not one-time tasks.
It can be done, though: have your cron job install a separate crontab file, replacing the existing one. At the end of your job (or at the beginning), do:
crontab my_new_crontab_file
Interesting idea.. but a little strange too. At least for this purpose, when I want to schedule one shot jobs. Your suggestion is to have one crontab file for each job and "chain them"?
You can keep several different crontab laying around and load them at will. Using 'crontab -e' you can edit the current crontab, and using 'crontab -l' you can dump the current crontab to stdout:
crontab -l > my_old_crontab_file
To address your earlier post about at:
Thanks for your input. I think rather than scripting around at, using lock files etc, I will write a python script with a scheduling queue and timers. I think that will work better for me. Thanks, Claes
On Wednesday 27 September 2006 19:08, Claes at work wrote:
It can be done, though: have your cron job install a separate crontab file, replacing the existing one. At the end of your job (or at the beginning), do:
crontab my_new_crontab_file
Interesting idea.. but a little strange too. At least for this purpose, when I want to schedule one shot jobs. Your suggestion is to have one crontab file for each job and "chain them"?
i wouldn't try it, no - too many potential problems and a pain in the butt to debug. But it might be a solution to what you're trying to do. A lock-file mechanism would be more practical and less error-prone, i think. Or, of course, what you suggested:
I will write a python script with a scheduling queue and timers. I think that will work better for me.
-- ----- stephan@s11n.net http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts
participants (5)
-
Andre Truter
-
Claes@work
-
Jan Engelhardt
-
John Andersen
-
stephan beal