I'm new to linux system and I'm trying to make a PHP script to be ran infinite times. Note that I'm using Debian 7
.
So, I'm using a screen
to open a window, so far so good, I have the worker.php
file already running succsefully, and I need to make shell script which runs the php script infinite times.
So I've come up with this:
#!/bin/sh
for (( ; ; ))
do
/usr/bin/php worker.php
sleep 1
done
The problem is , when trying to run ./worker.sh
in the screen
, I get this error:
bash: ./worker.sh: /bin/sh^M: bad interpreter: No such file or directory
So I've stripped of the for
, and replaced it with a simple echo
, which results into the same error, so I've wrote this question because I don't know what's wrong, both sh
or bash
exist on the server, I'm wondering if the shebang
is wrong but.. I have the automysqlbackup
script which starts with the same shebang
.
Do you have any idea what is wrong ? I'm just a newb.. don't really know much. If you're wondering why am I running a file every second, it's because this file serves as a commands processor from a queue in a game. And running it with cron every minute is too slow. MySQL triggers are not fitting my needs, so I'm forced doing this.
Regards.