Hello webmasters,

I am trying to create a script using vanilla PHP. I am familiar with the language and I have created a cronjob before, but only using cPanel. I want to create cronjobs using PHP if possible with out the need to go to cPanel.

I am trying to make it easier for users to install the script and make it hassle free.

So how can I run a cronjob using PHP?

Recommended Answers

All 2 Replies

The question "how to run a cronjob using PHP?" needs restatement. I can imagine managing cronjobs such as putting a job into the cron system, removal and such but run doesn't sound correct as the cron system will run the job for us, not PHP.

There are tutorials to manage cron such as https://code.tutsplus.com/tutorials/managing-cron-jobs-with-php--net-19428 but again, your question in my view needs refinement.

A cron job is a scheduled task that your operating system runs. The only way that a PHP script can make changes to what cron jobs run on a server is with admin privileges. The user would have to run the PHP script from the command-line as the root user. This isn't something that can be modified from a web interface.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.