TrophyWife
Contributor
Contributor

Automate VCSA 6.5 Backup - crontab Issue

Jump to solution

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!

1 Solution
7 Replies
virtualDD
Enthusiast
Enthusiast

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

0 Kudos
TrophyWife
Contributor
Contributor

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!

0 Kudos
TrophyWife
Contributor
Contributor

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.

0 Kudos
virtualDD
Enthusiast
Enthusiast

Great, thanks for linking the solution. I've updated my blogpost to include this fix. (I have been working on vSphere 6.0)

0 Kudos
vita1
Contributor
Contributor

Thanks for the post Smiley Happy and I use the same script that you used but I couldn't able to backup it says in progress an failed ... please find attached screenshot that I got.

Thanks,

0 Kudos
Tocano
Enthusiast
Enthusiast

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.

0 Kudos