TECHZEN Zenoss User Community ARCHIVE  

Cron

Subject: Cron
Author: [Not Specified]
Posted: 2015-02-12 16:03

Hello,
I have zenoss installed on Ubuntu 14.04 and am having some trouble getting cron to run the following script, however if I run it as root from the command line it executes the script without any errors. Running from cron produces no backup file.

# This script cleans up the temporary files in the renderserver as
# well as executes the zenbackup.py script, resulting in a database
# backup file being created.
#

# location of the shell script that initializes the zenoss environment
ZENOSS_ENV=~zenoss/.bashrc

# print the error message passed and exit with a return code of 1 (error)
fail() {
echo $*
exit 1
}

#
# main script starts here
#

# set up the environment
test -f ${ZENOSS_ENV} || fail "Source environment not found"
. ${ZENOSS_ENV}

# delete the renderserver files. they grow a LOT over time
test -d /tmp/renderserver && find /tmp/renderserver -name \*.png -exec rm '{}' \;

# run zenbackup to dump the events database as well as ZODB
su -c "${ZENHOME}/bin/zenbackup -C ${ZENHOME}/etc/zenbackup.conf < /dev/null" zenoss
su -c "find ${ZENHOME}/backups -type f -mtime +6 -name 'zenbackup_*' -exec rm -f {} \; > /dev/null" zenoss



Subject: Had a similar problem getting
Author: [Not Specified]
Posted: 2015-02-12 18:11

Had a similar problem getting scripts to run with the Zenoss environment intact, Solved it by executing a bash wrapper around the script, e.g. like this:

0 * * * * bash -ic "exec /home/zenoss/scripts/something_zenossy"



< Previous
Can't seem to connect to address
  Next
Failed Dependencies error
>