Cron
Can I make Cron to automaticly shutdown my computer? And if how do I do it? Must a user be loged in to run cron jobs?
I would like to just start the computer without logging in and then letting it automaticly shutdown later. |
> Can I make Cron to automaticly shutdown my computer?
Yes! >And if how do I do it? Must a user be loged in to run cron jobs? No, you don't have to be logged in. You can do it via the use of cron jobs. They're scripts / programs which can be scheduled to run at certain times (hourly, daily, weekly, once a year.. what have you). To shudown your machine you can use : shutdown -h now or more recently halt halt will call shutdown anyway, but may be easier to remember. I like to use the shutdown command because you won't find halt on other unix's (and I started on AIX so it's ingrained) To make this happen automatically : crontab -e - pulls up a blank editor for you to edit your cron jobs : 15 23 * * * /sbin/shutdown -h now - tells cron to execute the shutdown at 11:15pm every day :wq - writes the file. You're set. When you run crontab -e you're writing the crontab for that user and so they are the user who will execute the commands. So, you'll need to be root, or someone who has the privs to /sbin/shutdown. Shutdown has a couple of other flags instead of -h (halt). The other useful one -r does a reboot. And it can take a time as argument so, you might want to shutdown in 30 minutes you could shutdown -h +30 see man shutdown, man halt, man cron for all of the above. :) Slick. |
Thanks alot for the answer! Works perfectly.
|
All times are GMT -5. The time now is 04:15 AM. |