Dmitry T. Dmitry T. - 5 months ago 36
Bash Question

Chef run sh script

I have a problem trying to run shell script via Chef (with docker-provisioning).

This is how I try to execute my script:

bash 'shell_try' do
user "root"
run = "#{some_path_to_script}/my_script.sh some_params"
code " #{run} > stdout.txt 2> stderr.txt"
end


(note that this script should run another scripts, processes and write logs)

Here's no errors in the output, but when I log into machine and run
ps aux
process isn't running.

I guess something wrong with permissions (or env variables), because when I try the same command manually - it works.

Answer

A bash resource just runs the provided script text directly, if you wanted to run a long-running process generally you would set up an Upstart or systemd service and use the service resource to start it.

Comments