Skip to content

Tar does not run in a user's cron job

CentOS Initial task: Back up an application database (OpenEdge Progress). The backup_one.sh script stops the database, archives it with tar, uploads it to FTP, and starts the database. This inevitably produces output in STDOUT and STDERR. backup_all.sh runs backup_one.sh for each database listed in a file. Cron runs backup_all.sh overnight under a user account rather than root. backup_all.sh runs successfully in a console session under the same user.

Problem: When the database list is large (seven in this case), tar does not run for the final database. If the list is small (for example, two), everything succeeds.

Solution: Redirect all output from STDOUT, for example:

# a number 1 = standard out (i.e. STDOUT)
# a number 2 = standard error (i.e. STDERR)
command > /dev/null 2>&1