Ben Kilah
Ben Kilah

Reputation: 3475

Start a Linux job that has a loop

I'm trying to figure out how I can start a job I've created which runs a loop (that's another story).

The script is;

while [1];do
sleep 1
/usr/bin/php /var/www/mis/sms/sms_daemon.php > /dev/null 2>&1
done

When I run /etc/init.d/sms_daemon start (job I created) - it never returns back to the command prompt unless I hit ctrl-z or ctrl-c, which stops the service...

Upvotes: 1

Views: 101

Answers (1)

Black Diamond
Black Diamond

Reputation: 399

create a function & run that in the background

start_job(){
while [1];do
sleep 1
/usr/bin/php /var/www/mis/sms/sms_daemon.php > /dev/null 2>&1
done
}

start_job &

or

nohup start_job

Upvotes: 1

Related Questions