Reputation: 38332
How do i make the script auto-restart i think there is some issue in the last line .
#!/bin/bash
# a shell script that keeps looping until an exit code is given
php_command="php -q -f $1.php "
shift
nice $php_command $@
ERR=$?
..............
..............
exec $0 $@
I get the follwoing error exec: 36: ss.sh: not found
Upvotes: 1
Views: 1255
Reputation: 173522
You can use set -e
and a simple while
loop in bash:
#!/bin/sh
set -e
php_script=$1.php
shift
while true; do
php $php_script $@
done
Once the PHP script returns an exit code of non-zero the bash script will stop. If you need to run any code after the loop is done, you can do this instead:
while php $php_script $@; do
continue
done
Upvotes: 1
Reputation: 1
Rather than have the PHP script repeatedly executed, could this perhaps be changed to a loop within the PHP script itself?
Upvotes: 0