So today I learned about Cron. Cron is a way to schedule tasks to be completed automatically in Unix like operating systems. By editing one file you can schedule tasks to be completed by a specific user on a minute - weekly basis. I wanted to bug my sister so I added the following lines to /etc/crontab (Click for more)
#You need beep for this to work. It is in most distributions Repos
#Ignore the tildes (~) they are there for formatting reasons
*/10 * * * * root eject /dev/cdrom/
*/11 * * * * root mount /dev/cdrom/
*/3 * * * * root beep
# ^~~~~~~^~~~~^~~~~~~~^
# |~~~~~~|~~~~|~~~~~~~|------ Destination
# |~~~~~~|~~~~|-------------- Command
# |~~~~~~|------------------- User
# |------------------------------- Time
This means that every 10 minutes her cdrom tray pops out automatically, Every 11 minutes it pops back in automatically and every 3 minutes the internal speaker will beep.
The time syntax can be found in this chart
# ~+---------------- minute (0 - 59)
# ~|~+------------- hour (0 - 23)
# ~|~|~+---------- day of month (1 - 31)
# ~|~|~|~+------- month (1 - 12)
# ~|~|~|~|~+---- day of week (0 - 6) (Sunday=0 or 7)
# ~|~|~|~|~|
# ~*~*~*~*~* command to be executed
*/10 = every number thats divisible in time (days, hours weeks, etc)
* = every (minute, hour, day)
15 = (15th minute, 15th day, 15th hour, ect)
I annoyed her for a good hour before she figured out that I did something to her computer and that it wasn't just a bunch of glitches :D
Have fun playing around with cron. It is a very versatile and easy to use tool!
-Germ
btw, if you want to do this
btw, if you want to do this to a laptop realize that most laptop cd drives rely on the user pushing the drive back in. Also if you want a good cron gui check out gnome schedule.
Thanks alex :D
Thanks alex :D
no problem man, thanks to
no problem man, thanks to gnome-schedule I have really gotten much better with cron. Crontab is just really confusing for people not used to it.
germ that's evil! i hope
germ that's evil!
i hope your sister deserved it.
Post new comment