1

I have scheduled an @reboot cron job to start a service in /etc/init.d

After boot, service is not started when I reach shell command line. The contents of /var/log/cron show the following,

2022-09-27T17:16:03.913135-04:00 mtcap CROND[2147]: (root) CMDOUT (Stopping cgbscript)
2022-09-27T17:16:03.927646-04:00 mtcap CROND[2147]: (root) CMDOUT (/etc/init.d/cgbscript: line 21: start-stop-daemon: command not found)
2022-09-27T17:16:03.933438-04:00 mtcap CROND[2147]: (root) CMDOUT (Starting cgbscript)
2022-09-27T17:16:03.948336-04:00 mtcap CROND[2147]: (root) CMDOUT (/etc/init.d/cgbscript: line 11: start-stop-daemon: command not found)

If those are cut off on your screen, the error reported twice is,

start-stop-daemon: command not found

When I reach my shell prompt I can perform

# /etc/init.d/cgbscript start

and everything is just fine. I do not see start-stop-daemon located in /bin/ nor is it located in /sbin/. I am unable to perform # whereis start-stop-daemon because this is a tiny embedded system. Any ideas?

1 Answers1

0

Cron jobs are not executed in the same environment as the rest of the boot sequence. For this reason /usr/sbin/ is not in $PATH for those.

Alter the cgbscript so that start-stop-daemon appears with its absolute path.

/usr/sbin/start-stop-daemon

This fixes the problem.