Reputation: 3873
nohup php /home/www/api/24 > 24.out 2> 24.err < /dev/null
nohup php /home/www/api/27 > 27.out 2> 27.err < /dev/null
nohup php /home/www/api/19 > 27.out 2> 16.err < /dev/null
I have a few thousand api calls I need to make and need to be done one by one so I don't flood the other server with web calls. After I run the sh file, how can I close the terminal without interrupting the process, CTRL+Z ?
Upvotes: 1
Views: 118
Reputation: 1
You could also use the batch(1) command with a here document, e.g:
batch << EOJ
php /home/www/api/24 > 24.out 2> 24.err < /dev/null
php /home/www/api/17 > 17.out 2> 17.err < /dev/null
php /home/www/api/19 > 19.out 2> 19.err < /dev/null
EOJ
Upvotes: 1
Reputation: 179084
You type...
$ screen
...and hit enter.
Run the command or script.
Press control-a, then d
Then you can disconnect, log out, do whatever... come back later and check on the script:
$ screen -r
Then you wonder how you ever got along without it.
https://www.gnu.org/software/screen/
Upvotes: 4
Reputation: 781028
Put everything in a script, and then run that script with nohup
:
#!/bin/bash
for i in 24 27 19 ...
do
php /home/www/api/$i > $i.out 2> $i.err
done
Then do:
nohup /path/to/script </dev/null >/dev/null 2>&1 &
Upvotes: 2