This week I looked briefly at automating repetitive tasks with the CRON Utility. In this case, I wanted to shutdown/reboot...
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
the ESX server at a designated time. This was used in conjunction with ESX’s ability to automatically start-up and shutdown VMs.
Crond is a service which is used to schedule scripts of hourly/daily/weekly/monthly events. VMware utilizes this to run their own scripts, which can be seen in /etc/cron.daily, /etc/hourly and so on. Cron can also handle events such as: on reboot run this script with its @reboot syntax Along side these system-wide cron configurations you can also have per-user cron configurations. In my example, I’m using a per-user cron configuration to shutdown my servers at 9.30pm every evening. My development environment is accessible to some people – but due to physical limitations I cannot run my servers 24/7. So I need them to start-up in the morning and shut down in the evening.
- Logon to the Service Console as ROOT
- Create a cron configuration file in ROOT’s home directory with
nano -w crontab
- Type in this configuration:
30 21 * * * shutdown -h now
The path statements allow cron to find the shutdown utility which is held in /sbin. The command shutdown -h now causes ESX to do a full shutdown. The -h forces a halt which stops the swap file and un-mounts the drives. 30 21 is 9:30pmâ€¦
For more information about setting the time value see this link
- Save the contab fileâ€¦
- Register this configuration file with crontab with:
Confirm this has been registered with crond by listing the crontabs for root with:
If you wish to remove a scheduled event use:
- Restart the crond service with:
service crond restart