luqita
luqita

Reputation: 4087

Running cron job from browser

I have several cron jobs that run automatically, and I was requested to add a button that says 'run now' in the browser... Is this possible? Some of these cron jobs need to be executed from command line as they take around 15 minutes... Is it possible to execute them from the browser, not as a normal php function but somehow trigger an external php from the browser?

Upvotes: 0

Views: 2737

Answers (1)

Dennis
Dennis

Reputation: 14477

You're looking for the exec() function.

If it's a 15 minute task, you have to redirect its output and execute in in the background. Normally, exec() waits for the command to finish.

Example: exec("somecommand > /dev/null 2>/dev/null &");

Upvotes: 2

Related Questions