Scheduling tasks in linux – the at command



I did an article a while back about cron and scheduling tasks in linux (I also mentioned kron which is a graphical interface for cron scheduling…). That works well and good for things that happen on a recurring basis, but the next question is what if I want to schedule a command (or series of commands) to happen once and not again? Well, to tell the truth I’ve used cron for this on occasion, being sure to revisit the crontab and remove the entry before it repeats again, but there is a better way. At.


I could probably do a bad vaudeville-esque bit and say “at what..”, but there is a very powerful and simple scheduler called at in linux. If you open up a command shell and want to run the command “killall mplayer” to end all running mplayer processes at 10 pm, here’s how you’d do it…..

$at 10 pm
warning: commands will be executed using (in order) a) $SHELL b) login shell c) /bin/sh
at> killall mplayer
at>
job 12 at 2006-01-16 22:00

So, I typed “at 10 pm” (without the quotes) a the $ prompt… it gave me an interactive way of entering commands…. next I typed “killall mplayer” (and pressed enter), then since I didn’t have another command I wanted to schedule, I merely pressed ctrl-d to exit and was promptly told that the task was scheduled for 2200 hours tonight (which is 10 pm).

at can handle fairly human-friendly time scheduling…. at 5 tuesday for instance would schedule for 5 am on tuesday (today is Monday and so it schedules for tomorrow, but it is swift enough to figure that if the time has already passed for the week, then it will do it the next time it comes around.)

atq can show what’s scheduled…
$ atq
13 2006-01-17 05:00 a avery
12 2006-01-16 22:00 a avery
$

atrm can remove scheduled tasks…. atrm 13
atrm 12
for instance removes the above entries….

it’s also possible to feed at a file with a list of commands…. at -f listofcommands.txt
the format is usually one command per line. More information on at is available by typing “man at”
(again without the quotes) at the command line.

Related Posts

Blog Traffic Exchange Related Posts
  • Evolution email error MAIL FROM command failed: Unknown Some time back, I was teetering on the brink.... I've used Evolution as my linux mail client for ages (since I switched), because it had the calender integrated etc... However, Kontact has REALLY looked nice for some time, but I didn't have time to mess with changing. Then one day,......
  • Another Dumaru variant Sunbelt has found another keylogger in the dumaru family and has updated their free tool to scan for it and clean it up. This is the same family of trojans/keyloggers that contributed to the large ID theft discovery they made earlier in the month. From their post... The SSA-KeyLogger spyware......
  • Remote Tech Support using VNC (Ultravnc SC and x11vnc+wrapper script) Ok, some time back I'd done a writeup on UltraVNC SC, which is a nice customizable (windows version) VNC server that essentially let's someone doing remote support build their own downloadable .exe that runs and automatically tries to make a direct connection to a "listening" vnc viewer. It's good for......
Blog Traffic Exchange Related Websites
  • Are Demons forced to do as Christ commands? Are Demons forced to do as Christ commands: God is omnipotent. Meaning he can do all things. If Christ, as the incarnation of God, were unable to command demons then one could not say Christ is omnipotent. According to Scripture, all things are subject to the permissive will of God.......
  • Free Help for Household and Technology Product Repairs Baby boomers typically own a lot of "stuff" around the house.  It seems that one thing or another is always in need of repair.  If its a kitchen appliance or some electronic gadget, our tendency is to just throw it away because the actual or perceived cost of repair exceeds......
  • Tech Support - Funny Video Series While surfing through Youtube, I stumbled across this fun-filled tech support video series. All of the videos are sure to give you good amount of chuckle. I liked all of them, but first one is my favorite. Surely a stress buster after a bad day in office :) Enjoy! Tech......
PDF24    Send article as PDF   

Similar Posts


See what happened this day in history from either BBC Wikipedia
Search:
Keywords:
Amazon Logo

Comments are closed.


Switch to our mobile site