salt icon indicating copy to clipboard operation
salt copied to clipboard

salt-call state.highstate service state error when running through cron job

Open hernanc opened this issue 12 years ago • 1 comments

Minion version: 0.17.4

Hi there,

I have a highstate that, among other things, checks that nginx and postgre services are running. It all works OK when I run it from the master or even from the minion by running: salt-call state.highstate

But, if I add a crontab to run it from the minion: */5 * * * * salt-call state.highstate

It throws this error on every service it checks:

[INFO ] Executing command 'service nginx status' in directory '/root' [ERROR ] An exception occurred in this state: Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/salt/state.py", line 1305, in call _cdata['args'], *_cdata['kwargs']) File "/usr/lib/pymodules/python2.7/salt/states/service.py", line 281, in running return _enable(name, None, **kwargs) File "/usr/lib/pymodules/python2.7/salt/states/service.py", line 108, in _enable if salt['service.enable'](name, **kwargs): File "/usr/lib/pymodules/python2.7/salt/modules/upstart.py", line 436, in enable executable = _get_service_exec() File "/usr/lib/pymodules/python2.7/salt/modules/upstart.py", line 400, in _get_service_exec salt.utils.check_or_die(executable) File "/usr/lib/pymodules/python2.7/salt/utils/init.py", line 585, in check_or_die raise CommandNotFoundError(command) CommandNotFoundError: update-rc.d

[INFO ] Executing command 'service postgresql status' in directory '/root' [ERROR ] An exception occurred in this state: Traceback (most recent call last): File "/usr/lib/pymodules/python2.7/salt/state.py", line 1305, in call _cdata['args'], *_cdata['kwargs']) File "/usr/lib/pymodules/python2.7/salt/states/service.py", line 281, in running return _enable(name, None, **kwargs) File "/usr/lib/pymodules/python2.7/salt/states/service.py", line 108, in _enable if salt['service.enable'](name, **kwargs): File "/usr/lib/pymodules/python2.7/salt/modules/upstart.py", line 436, in enable executable = _get_service_exec() File "/usr/lib/pymodules/python2.7/salt/modules/upstart.py", line 400, in _get_service_exec salt.utils.check_or_die(executable) File "/usr/lib/pymodules/python2.7/salt/utils/init.py", line 585, in check_or_die raise CommandNotFoundError(command) CommandNotFoundError: update-rc.d

And so on with the other services. Probably Maybe I'm missing an EVN var?

Thanks! H

hernanc avatar Jan 08 '14 00:01 hernanc

Yes, I think you just need to set your path correctly in your cron script: http://stackoverflow.com/questions/2388087/how-to-get-cron-to-call-in-the-correct-paths

basepi avatar Jan 08 '14 22:01 basepi