Control services from cron

Is there a trick to controlling services from cron?

I tried both of these:

* * * * * stopservice ServiceName > stopser.txt
* * * * * service ServiceName stop > stopserv2.txt

Either of these commands work from ssh, but not from cron.

Cron is working, becuase I'm able to run this:
* * * * * env > cronenv.txt

and get

USER=root
SHLVL=1
HOME=/root
LOGNAME=root
TERM=linux
PATH=/usr/sbin:/usr/bin:/sbin:/bin
SHELL=/bin/sh
PWD=/root

https://openwrt.org/docs/guide-user/base-system/managing_services#command-line_interface

3 Likes

Exactly what I was looking for, Thanks!

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.