/usr/share/otrs/bin/Cron.sh is in otrs2 6.0.5-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | #!/bin/sh
# --
# Copyright (C) 2001-2018 OTRS AG, http://otrs.com/
# --
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU AFFERO General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# or see http://www.gnu.org/licenses/agpl.txt.
# --
CURRENTUSER=`whoami`
CRON_USER="$2"
# check if a common user try to use -u
if test -n "$CRON_USER"; then
if test $CURRENTUSER != root; then
echo "Run this script just as OTRS user! Or use 'Cron.sh {start|stop|restart} OTRS_USER' as root!"
exit 5
fi
fi
# check if the cron user is specified
if test -z "$CRON_USER"; then
if test $CURRENTUSER = root; then
echo "Run this script just as OTRS user! Or use 'Cron.sh {start|stop|restart} OTRS_USER' as root!"
exit 5
fi
fi
# find otrs root
cd "`dirname $0`/../"
OTRS_HOME="`pwd`"
#OTRS_ROOT=/opt/otrs
if test -e $OTRS_HOME/var/cron; then
OTRS_ROOT=$OTRS_HOME
else
echo "No cronjobs in $OTRS_HOME/var/cron found!";
echo " * Check the \$HOME (/etc/passwd) of the OTRS user. It must be the root dir of your OTRS system (e. g. /opt/otrs). ";
exit 5;
fi
CRON_DIR=$OTRS_ROOT/var/cron
CRON_TMP_FILE=$OTRS_ROOT/var/tmp/otrs-cron-tmp.$$
#
# main part
#
case "$1" in
# ------------------------------------------------------
# start
# ------------------------------------------------------
start)
# add -u to cron user if user exists
if test -n "$CRON_USER"; then
CRON_USER=" -u $CRON_USER"
fi
if mkdir -p $CRON_DIR; cd $CRON_DIR && ls -d * | grep -Ev "(\.(dist|rpm|bak|backup|custom_backup|save|swp)|\~)$" | xargs cat > $CRON_TMP_FILE && crontab $CRON_USER $CRON_TMP_FILE; then
rm -rf $CRON_TMP_FILE
echo "(using $OTRS_ROOT) done";
exit 0;
else
echo "failed";
exit 1;
fi
;;
# ------------------------------------------------------
# stop
# ------------------------------------------------------
stop)
# add -u to cron user if user exists
if test -n "$CRON_USER"; then
CRON_USER=" -u $CRON_USER"
fi
if crontab $CRON_USER -r ; then
echo "done";
exit 0;
else
echo "failed";
exit 1;
fi
;;
# ------------------------------------------------------
# restart
# ------------------------------------------------------
restart)
$0 stop "$CRON_USER"
$0 start "$CRON_USER"
;;
# ------------------------------------------------------
# Usage
# ------------------------------------------------------
*)
cat - <<HELP
Manage OTRS cron jobs.
Usage:
Cron.sh [action]
Arguments:
[action] - 'start', 'stop' or 'restart' - activate or deactivate OTRS cron jobs.
HELP
exit 1
esac
|