• Increase font size
  • Default font size
  • Decrease font size
Start Hardware / Software Eigene Software PHP scripts archive - pseudo-cron

PHP scripts archive - pseudo-cron

PHP scripts archive
PHP vCard class
Alle Seiten

Usually regular tasks like backup up the site's database are run using cron jobs. With cron jobs, you can exactly plan when a certain command is to be executed. But most homepage owners can't create cron jobs on their web server – providers demand some extra money for that.
The only thing that's certain to happen quite regularly on a web page are page requests. This is where pseudo-cron comes into play: With every page request it checks if any cron jobs should have been run since the previous request. If there are, they are run and logged.

Pseudo-cron uses a syntax very much like the Unix cron's one. For an overview of the syntax used, see a page of the UNIXGEEKS. The syntax pseudo-cron uses is different from the one described on that page in the following points:

  • there is no user column
  • the executed command has to be an include()able file (which may contain further PHP code)
All job definitions are made in a text file on the server with a user-definable name (usually crontab.txt). Here is an example of a valid crontab file:


#comments start with '#'

#mi h d m dow job comment
0 5 * * Sun cronjobs/dump.inc.php # make db dump every sunday at 5 am
40 5 2 * * cronjobs/sendlog.inc.php # send last month's web server logs
*/15 8-19 * * Mon-Fri cronjobs/refr_ext.inc.php # refresh external news sources


  • runs any PHP script
  • periodical or time-controlled script execution
  • logs all executed jobs
  • can be run from an IMG tag in an HTML page
  • follows Unix cron syntax for crontabs
  • sends an email with the results


Download Download (ZIP file, 13 KB)


  1. Modify the variables in the config section below to match your server.
  2. Write a PHP script that does the job you want to be run regularly. Be sure that any paths in it are relative to the script that include()s pseudo-cron.
  3. Set up your crontab file with your script.
  4. Include pseudo-cron.inc.php in a high traffic page.
  5. Wait for the next scheduled run :)
Note: You can log messages from your job script to pseudo-cron's log file by calling logMessage("log a message").


Design by i-cons.ch / etosha-namibia.ch