How do i run a command every day at a certain time automatically?
Hey guys.
I am a noob. I just want to know how to make a command automatically run EVERY DAY at a certain time. I want it to run /sbin/shutdown -h 22:00. This needs to run everyday at 10:00PM. Can someone tell me how i can make it do it automatically? Thanks. |
Hello.
I think most systems support a thing called cron. Cron can get a bit tricky but if you remember cron is sort of like a user with it's own rights and authentication then you are OK. You want to run that script before to be sure it runs. |
Thanks, but what do i have to enter into the terminal to have it shutdown everyday at 10:00?
|
As root, or after sudo, edit /etc/crontab.
Enter this line at the end: Code:
0 22 * * * root shutdown -h now If you are a GUI only person, you can edit a file as root by pressing CTL-F2 and tell that you want to run an application as root, and then choose you fav editor jlinkels |
You might want to specify the complete path to the shutdown command in your cronjob: /sbin/shutdown
|
Quote:
Code:
crontab -e Note: for a shutdown command, it would need to be done as root, as stated in other replies. Unless passwordless shutdown has been enabled in sudoers. |
Quote:
The shutdown command has to be run as root, and it really fits better in the system-wide /etc/crontab. If you are right and shutdown can be run by a member of the sudoers group a personal crontab might work, but it makes the system less transparent. You don't want to go through a dozen crontabs to see who is responsible for shutting down the machine. jlinkels |
All times are GMT -5. The time now is 08:03 PM. |