Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2786735
  • 博文数量: 423
  • 博客积分: 7770
  • 博客等级: 少将
  • 技术积分: 4766
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-09 11:58
个人简介

Oracle/DB2/Postgresql/Mysql/Hadoop/Greenplum/Postgres-xl/Mongodb

文章分类

全部博文(423)

文章存档

2019年(3)

2018年(6)

2017年(27)

2016年(23)

2015年(30)

2014年(16)

2013年(31)

2012年(73)

2011年(45)

2010年(14)

2009年(30)

2008年(30)

2007年(63)

2006年(32)

分类: LINUX

2011-02-28 17:10:23

This explains how to add a cron job to VMware in such a way that it will still be there after reboots.

Having
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)
    */2 * * * * /vmfs/volumes/datastore1/kkk.sh
  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
  5. if no reboot     # busybox crond
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 .

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 "*/2 * * * * /vmfs/volumes/datastore1/kkk.sh" >> /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.
阅读(1980) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~