Jump to content

PHP time based scritps help


barefootsanders

Recommended Posts

Assuming it's a unix-like server, write any script and set a cron job to run it.  You can write a PHP script which is called from the command line.  There's plenty of cron documentation online.

 

interesting, i would love to learn about this ability however i am on a shared cpanel-utilizing host. is this still possible?

 

HoTDaWg

Link to comment
Share on other sites

Assuming it's a unix-like server, write any script and set a cron job to run it.  You can write a PHP script which is called from the command line.  There's plenty of cron documentation online.

 

Is there a way to set one of these up through phpmyadmin or can you only create one through direct MySQL inputs?

Link to comment
Share on other sites

My shared host allows it.  I have SSH access and use crontab at the command line to set up my cron jobs.  I don't know about cpanel but I assume it's up to the specific host.

 

One side note: my shared host seems to limit CPU usage for crons.  So if you have an intensive or long-running script some hosts have their systems set up to terminate them.

Link to comment
Share on other sites

Is there a way to set one of these up through phpmyadmin or can you only create one through direct MySQL inputs?

 

It has nothing to do with mysql.  You can write a script in PHP (or other languages) which connects to mysql and edits records, then have a cron run that script periodically.

Link to comment
Share on other sites

Is there a way to set one of these up through phpmyadmin or can you only create one through direct MySQL inputs?

 

It has nothing to do with mysql.  You can write a script in PHP (or other languages) which connects to mysql and edits records, then have a cron run that script periodically.

 

I understand that, however I am unsure on how to write a cron and how to enable that cron through phpmyadmin.  Any help would be apprecaited.

Link to comment
Share on other sites

The only problem with what veridicus says is that someone HAS to hit a page every so often for that cronjob to be ran. Let's say no one hits a webpage for 3 days, none of those jobs are going to be ran because there is nothing to execute that code.

 

That is the handy thing about having access to shell console on linux, they have true cronjobs that WILL run every so many minutes.

 

A workaround is to host the cronjob on a separate site (search for cronjob hosting) and have it run a page on your site, that way you are sure that page will be  ran without having to slow users down etc.

Link to comment
Share on other sites

The only problem with what veridicus says is that someone HAS to hit a page every so often for that cronjob to be ran. Let's say no one hits a webpage for 3 days, none of those jobs are going to be ran because there is nothing to execute that code.

 

That is the handy thing about having access to shell console on linux, they have true cronjobs that WILL run every so many minutes.

 

A workaround is to host the cronjob on a separate site (search for cronjob hosting) and have it run a page on your site, that way you are sure that page will be  ran without having to slow users down etc.

 

How do you know if you have access to the shell console on linux?

Link to comment
Share on other sites

The only problem with what veridicus says is that someone HAS to hit a page every so often for that cronjob to be ran. Let's say no one hits a webpage for 3 days, none of those jobs are going to be ran because there is nothing to execute that code.

 

That is the handy thing about having access to shell console on linux, they have true cronjobs that WILL run every so many minutes.

 

I was referring to server cron jobs, not hoping a page gets hit.  PHP scripts can be run at the command line, so they can also be called from server cron jobs on the local host.

 

How do you know if you have access to the shell console on linux?

 

Assuming you're on a shared web host, check for "SSH access" to your account.  Some hosts also distinctly advertise the ability to run cron jobs.

Link to comment
Share on other sites

You can run cron job no problem in cPanel.  Just log into your cPpanel account and click on the Cron Jobs Icon and set up your cron using either the Standard or Advanced (Unix Style) and set it to when you want the script to run and how often.  You can find more information on this by searching the net with your favorite search engine for using cron for cpanel, or check the cPanel site, they should have some information.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.