how to add stuff to crontab without using crontab -e

Antonio Olivares olivares14031 at yahoo.com
Mon Apr 13 03:23:57 UTC 2009


Dear fellow Fedora users,

I want to know if it is possible to edit/append to crontab without using crontab -e.  I have about 10 machines running Fedora and at the end of the day I have to manually power them off (shutdown).  For a while, I started thinking about it, well I can make a crontab to shutdown the machines at a certain time:

Edit crontab to shutdown machines from student account at 4:15 every day(Monday-Friday) at school :)  This way I don't have to shut them down myself :)

$ which poweroff


If crontab is empty I want to add the following to it, so that the machines can shutdown by themselves at 4:15 pm.  

# min hour day-of-month month day-of-week command
15 16 * * 1-5 /usr/bin/poweroff  >& /dev/null

I can manually type this for each of the 12 machines, but I thought it would be more efficient to do something like

#!/bin/bash
#
crontab -e << "# min hour day-of-month month day-of-week command" \
"15 16 * * 1-5 /usr/bin/poweroff  >& /dev/null " \
EOF >>

or something similar to apply it to all machines via a usb stick and avoid the typing. How can I correct the above script to do the job, if there is way to do it.

I have done it manually and it will work, but how can I do it with a script to do it more efficiently?  

Thank you in advance for your help/guidance/suggestions/advice.

Regards,

Antonio 


      




More information about the users mailing list