Hi Steve,
Have you made sure you are redirecting the command's stdout/stderr?
(salt-dev)root@web1:/# cat /tmp/sleep.sh
#!/bin/sh
sleep 30
echo awake
(salt-dev)root@salt:/srv/salt/base# cat sleeper.sls
run_cmd:
cmd.run:
- name: '/tmp/sleep.sh &'
(salt-dev)root@web1:/# time salt-call state.sls sleeper
local:
----------
ID: run_cmd
Function: cmd.run
Name: /tmp/sleep.sh &
Result: True
Comment: Command "/tmp/sleep.sh &" run
Changes:
----------
pid:
8562
retcode:
0
stderr:
stdout:
awake
Summary
------------
Succeeded: 1
Failed: 0
------------
Total: 1
real 0m32.514s
user 0m0.918s
sys 0m0.202s
If you make sure you redirect stdout/stderr, you should be able to
background the process:
(salt-dev)root@salt:/srv/salt/base# cat sleeper.sls
run_cmd:
cmd.run:
- name: '/tmp/sleep.sh >/dev/null 2>&1 &'
(salt-dev)root@web1:/# time salt-call state.sls sleeper
local:
----------
ID: run_cmd
Function: cmd.run
Name: /tmp/sleep.sh >/dev/null 2>&1 &
Result: True
Comment: Command "/tmp/sleep.sh >/dev/null 2>&1 &" run
Changes:
----------
pid:
8634
retcode:
0
stderr:
stdout:
Summary
------------
Succeeded: 1
Failed: 0
------------
Total: 1
real 0m2.362s
user 0m0.928s
sys 0m0.214s
(salt-dev)root@web1:/# ps wwauxf | grep sleep
root 8635 0.0 0.0 9396 1296 pts/0 S 04:07 0:00 /bin/sh /tmp/sleep.sh
root 8638 0.0 0.0 4048 540 pts/0 S 04:07 0:00 \_ sleep 30
--
Dave