First: Essentially I'm a basic knowledge Linux admin.
I set up vCSA 6.5 backup using this great article:
https://vm.knutsson.it/2017/01/vmware-vcsa-6-5-scheduled-backup/
Running the script manually works perfect.
However, I am not able to get the crontab automatic job working. From my testing, it's not running at all.
Putty'd to VCSA.
Launched crontab -e
It looks like this:
0 19 * * * /usr/local/bin/vCSA-Backup.sh
Saved and get:
crontab: installing new crontab
No backup.
In an article, I saw this recommendation to see if cron is running the crontab at all:
0 19 * * * touch /tmp/a_command_has_run
This makes a file in /tmp apparently and I ran it manually to confirm it does.
No file created from the automated job.
When I look at time it is showing UTC, but in case this is a time zone issue, I checked after an overnight where it should have run in either time zone and got nothing.
So just in case of a time zone problem, I modified the crontab to make two files based on time.
0 17 * * * touch /tmp/a_command_has_run17
0 12 * * * touch /tmp/a_command_has_run12
Neither were made.
I would appreciate any direction on this issue.
Thanks!
And I found the fix in this article:
Hi,
based on your information I can tell you why it won't work. When you run the script manually you are logged into the shell bash. When you use crontab to run a script you need to run bash and pass the script as a argument. Like so:
0 19 * * * /bin/bash /usr/local/bin/vCSA-Backup.sh
As for your problem with the binary "touch": always use the full path to binaries in crontab. you can find out the exact path of a binary by issuing "which <binary>" like "which touch" it will give you the path. probably /bin/touch or /sbin/touch. the reason for this is simple. when the cron daemon runs a job it does not have a profile and no path variables so it won't find the binaries if you don't give it the full path to it.
hope this helps.
edit: I wrote a blog post about a different approach to the subject: Automating VCSA Backup & Restore – virtualfrog – daily virtual life
Ah....my Linux newb-ness has been revealed. Thanks for the help.
I will adjust the crontab and also check out your blog post.
Very much appreciated!
Unfortunately, the cron jobs are still not running.
My latest attempt looks like this:
root@VCENTER [ /tmp ]# crontab -l
0 * * * * /bin/bash /usr/bin/touch /tmp/a_command_has_run999
I noticed in the VCSA GUI that Bash was disabled. I enabled it (count down timer ensued), but didn't make a difference.
I have no evidence it tries to run.
And I found the fix in this article:
Great, thanks for linking the solution. I've updated my blogpost to include this fix. (I have been working on vSphere 6.0)
Looks like the blog author reorganized his URLs (took dates out) and broke the link given above.
Here's the updated link:
https://www.drewgreen.net/fix-for-cron-failing-on-vmware-vcenter-server-appliance-vcsa-6-5/
To summarize (in case page again gets lost):
Errors occur using the default /etc/pam.d/crond config:
account required pam_access.so
account include password-auth
session required pam_loginuid.so
session include password
-auth
auth include password
-auth
First, make a backup copy of this file, then edit the original, replacing the 3 "password-auth" references with "system-auth":
account required pam_access.so
account include system-auth
session required pam_loginuid.so
session include system-auth
auth include system-auth
This resolved my issue with cron jobs failing to run as well.