2. Edit "vi /var/spool/cron/crontabs/root" (to wrtire press i, delete line <esc> :d <enter>, to save <esc> :wq! <enter>)
3. Add the line (all on one line) 5 0 * * * /full/path/to/script arguments/with/full/path > /full/path/to/logfile 2>&1
10 6 * * 0 /vmfs/volumes/datastore1/trintukas.sh >> /vmfs/volumes/datastore1/trintukas.log
* * * * * is minute hour (military time) day month weekday (Sunday=0, Monday = 1, Tuesday = 2, and so on)
Help -> http://www.generateit.net/cron-job/
4. Run the command "cat /var/run/crond.pid"
5. Run the command "kill 12345" where "12345" should be replaced with the number output by the previous command
6. Restart cron "/usr/lib/vmware/busybox/bin/busybox crond"
7. Issue command "auto-backup.sh"
Now cron will start working but all it's setting will be lost after the reboot. To inject commands into crontab do the following:
8. Edit /etc/rc.local.d/local.sh
At the end of the file right before the "exit 0" statement write this:
/bin/kill $(cat /var/run/crond.pid) # Gets the cron service pid and simply kills it.
/bin/echo '15 6 * * 0 /vmfs/volumes/datastore1/xsibackup --backup-point="192.99.148.50:22:/vmfs/volumes/datastore1/Backup" --backup-type=running >> /vmfs/volumes/datastore1/xsibackup-cron.log' >> /var/spool/cron/crontabs/root
/usr/lib/vmware/busybox/bin/busybox crond
save the file (<esc> :wq <enter>)
9. Run the command "auto-backup.sh" so that the change to/etc/rc.local survives a reboot.
10. OPTIONAL: reboot the server to see if everything works.
*IMPORTANT: ESXi inside runs on UTC time even on Vsphere client it
shows othertime. When giving time commands on crontab please use UTC
time. You can check ESXi time with command "date".
Tidak ada komentar:
Posting Komentar