Cron not working

Permissions, domain/LDAP, power, security, notification and more.
Locked
User avatar
sybarix
Posts: 15
Joined: 28 Nov 2021, 08:13

Cron not working

Post by sybarix »

Running "service cron status" on TOS 5.0.171 returns the following:

Code: Select all

[DEBUG /etc/init.d/cron status]
[DEBUG /etc/init.d/cron: line 52: [: too many arguments
]
stopped
This does not change after running "service cron start".

I can't seem to attach the cron file here so here are the contents of /etc/init.d/cron

Code: Select all

#!/bin/bash

source /etc/profile >/dev/null
DAEMON=crond
realconfig=/etc/crontabs
config=/var/spool/cron/crontabs
LOG_FILE=/var/log/crond.log
vmpid=/var/run/cron_vmtouch.pid

crontab_modify() {
    local key=$1
    local cmd=$2
    if [ $(grep -c "${key}" $realconfig/root) -eq 0 ]; then
        echo "$cmd" >>$realconfig/root
    fi
}

service_init() {
    [ ! -f $realconfig/root ] && touch $realconfig/root
    crontab_modify "everyminuteexec" "*/1 * * * * /etc/init.d/nas/everyminuteexec"
    crontab_modify "everyhourexec" "10 * * * * /etc/init.d/nas/everyhourexec"
    crontab_modify "everydayexec" "0 12 * * * /etc/init.d/nas/everydayexec"
    sed -i '/ntpdate/d' $realconfig/root
    sed -i '/^$/d' $realconfig/root
    rm -fr $config >/dev/null 2>&1
    mkdir -p $config

    cp $realconfig/root $config/root -a
    id root >/dev/null 2>&1
    if [ $? -ne 0 ]; then
        cp $realconfig/root $config/$admin -a
    fi
    if [ ! -e $vmpid ]; then
        vmtouch -ld /etc/init.d/nas/everyminuteexec /etc/init.d/nas/everyhourexec /etc/init.d/nas/everydayexec -P $vmpid
    fi
}

service_start() {
    service_init

    local pid=$(pidof crond)
    if [ -z "$pid" ]; then
        $DAEMON -L $LOG_FILE
    fi
}

service_stop() {
    killall -9 $DAEMON >/dev/null
}
service_status() {
    local pid=$(pidof crond)
    if [ ! -z $pid ]; then
        echo "running"
    else
        echo "stopped"
    fi
}

case $1 in
start)
    service_start
    exit 0
    ;;
stop)
    service_stop
    exit 0
    ;;
status)
    service_status
    exit 0
    ;;
restart)
    service_stop
    sleep 1
    service_start
    exit 0
    ;;
*)
    echo "$0 start|stop|restart"
    exit 1
    ;;
esac
Locked