1

I have some cronjobs that I always used and worked fine. But now, trying to move everything to Docker containers, I'm running into these errors:

/usr/bin/service: 127: /usr/bin/service: stop: not found
/usr/bin/service: 128: exec: start: not found

They occur when executing things like "service restart nginx" these cronjobs. Note that the same commands work fine outside the cronjobs.

The PATH is correctly set in /etc/crontab . Adding it to the individual cronfiles in /etc/cron.d doesn't work either. I also tried changing SHELL=/bin/sh to SHELL=/bin/bash (even though it's insecure, but wanted to try) in /etc/crontab, didn't work.

Any ideas?

NorthCat
  • 9,643
  • 16
  • 47
  • 50
ChocoDeveloper
  • 14,160
  • 26
  • 79
  • 117
  • might want to refer to this q: http://stackoverflow.com/questions/20545554/how-do-i-start-cron-on-docker-ubuntu-base – sirvon Mar 20 '14 at 22:47
  • @sirvon That doesn't really talk about my issue, it just says how to install and execute cron. My crons are running, but they throw errors when they call "service xxx restart" or "service xxx status". – ChocoDeveloper Mar 20 '14 at 22:51
  • maybe inside your containers the proper init mechanisms aren't active like .. /sbin/init or upstart or such.... – sirvon Mar 20 '14 at 23:08
  • @sirvon I forgot to mention that it works fine outside the cronjobs. – ChocoDeveloper Mar 20 '14 at 23:36

2 Answers2

1

I solved it changing the command from

"service start mysql"

to

"/sbin/start mysql &"

Good luck

Enric

NorthCat
  • 9,643
  • 16
  • 47
  • 50
0

I am not sure, but I think that the problem is in paths. I believe you want to run /usr/sbin/service and not /usr/bin/service. You may try to specify full path for service instead of just service.

Jiri
  • 16,425
  • 6
  • 52
  • 68