Jessica Lingmn
Jessica Lingmn

Reputation: 1212

Running an infinite loop in cron job

Running an infinite loop in cron job.
Suppose, i have written a php based script to run on my server computer using cron job, and i want to use infinite loop in that php script.
Any ideas for running an infinite loop in cron job.

Upvotes: 4

Views: 2043

Answers (1)

Mihai Stancu
Mihai Stancu

Reputation: 16127

Infinite looping applications are usually called daemons. They are system services that offer some kind of constant processing and/or the readiness to accept some potential incoming processing activities.

Gearman is a system daemon you can install than can handle various tasks you give it. It's a complex tools that allows many things but it could be used to implement your necessities.

PHP::Gearman is a Gearman client that talks to the Gearman daemon and sends tasks to the daemon specifying the conditions under which the task must be executed.

The limitations that @Jeffrey emphasized about PHP are true because PHP was designed as a share nothing architecture (one page load equals one script execution - each page load works under its own data context).

Perhaps System Daemon (a pear package) may assist in overcoming some or all of the limitations mentioned above. I haven't used it so I can't tell you much more about it but it's as good a place to start as any.

Upvotes: 3

Related Questions