Good Morning! trying to start a script on multiple servers w/ nohup and keep it running in the back ground.
The command (provided by my vendor) runs as expected when inputting directly on each server (the python script scrapes the log file and sends relevant info to another server via UDP):
nohup tail -f /log/log.log | python /test/deliver.py > /dev/null 2>&1 &
However, when placing into for loop to reach many servers, I must press Ctrl-C between each server to keep the loop going.
Please assist if possible:
for i in `cat /etc/hosts`; do ssh $i nohup tail -f /log/log.log | python /test/deliver.py > /dev/null 2>&1 &; done
Solution (Thank you all for the help):
ssh -f user@host "cd /whereever; nohup ./whatever > /dev/null 2>&1 &"
Had to use the -f in combination with double quotes as described here:
Getting ssh to execute a command in the background on target machine