Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » 云计算  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to topicflat modethreaded modego to previous topicgo to next topicgo to back
作者 ESXi添加定时计划任务Add cron Job to VMware ESX/ESXi
阿熊

阿熊

元老


发贴: 5644
于 2017-12-01 01:36 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
This explains how to add a cron job to VMware in such a way that it will still be there after reboots.

Having enabled ssh access to your ESX/ESXi server, ssh in as root.

Firstly, add the cron job to the root crontab:

1.Edit /var/spool/cron/crontabs/root
2.Add the line (all on one line)
5 0 * * * /full/path/to/script arguments/with/full/path > /full/path/to/logfile 2>&1
3.Run the command "cat /var/run/crond.pid"
That will print the process number of the running crond, such as 12345
4.Run the command "kill 12345"
where "12345" should be replaced with the number output by the previous command

For details of the meaning of "5 0 * * *" (5 minutes past midnight every day) read the man page for crontab(5) on any Unix/Linux server, or else on the web.

Now, add a command to /etc/rc.local to re-generate the cron job when ESX/ESXi reboots

1.Edit /etc/rc.local, using a command such as "vi /etc/rc.local".
2.At the end of the file, add 3 lines (using "G" then "O" in vi). The first kills crond, the second adds the new cron job to the root crontab file, ad the third restarts crond:
/bin/kill $(cat /var/run/crond.pid)
/bin/echo '5 0 * * * /full/path/to/script arguments/with/full/path > /full/path/to/logfile 2>&1' >> /var/spool/cron/crontabs/root
/bin/busybox crond
3.Save and exit the editor (Press the "Esc" key then ":wq" then press "Return" in vi)
4.Run the command "auto-backup.sh" so that the change to /etc/rc.local survives a reboot.

Every time you change the cron job, remember to update /etc/rc.local as well and run the "auto-backup.sh" command to backup the new /etc/rc.local file.

Link From: http://www.jules.fm/Logbook/files/add_cron_job_vmware.html




reply to topicflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923