dotfiles/termux/services/crond
2017-09-17 14:34:37 +00:00

62 lines
918 B
Bash
Executable file

#!/data/data/com.termux/files/usr/bin/bash
#
# Start crond
#
PIDFILE="$HOME/.local/run/crond.pid"
LOGFILE="$HOME/.local/log/crond.log"
start() {
printf "Starting crond: "
start-stop-daemon -p "$PIDFILE" -x crond -S -b -m -- -f -L "$LOGFILE"
termux-toast "Started crond"
echo "OK"
}
stop() {
printf "Stopping crond: "
start-stop-daemon -p "$PIDFILE" -x crond -K
termux-toast "Stopped crond"
echo "OK"
}
status() {
printf "crond: "
PID="$(cat "$PIDFILE" 2> /dev/null)"
if [[ -n "$PID" && -d "/proc/$PID" ]]
then
echo "running"
else
echo "stopped"
fi
}
log() {
tail "$@" "$LOGFILE"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
status)
status
;;
log)
shift
log "$@"
;;
*)
echo "Usage: $0 {start|stop|restart|status|log}"
exit 1
esac
exit $?