Member Avatar for doctorphp

Hi everyone,

I have setup a cron job to delete users from my site if they are not verified within 24 hours of registration. The field registration_timestamp is stored as a timestamp and I also have a field called verified which is stored as a 1 or a 0. Here is the code for the cron job.

<?php
///connection stuff
mysql_query("DELETE FROM users WHERE ((TO_DAYS(CURDATE()) - TO_DAYS(registration_timestamp)) >= 1) AND verified='0'");
?>

I run the cron every five minutes and I checked on a dummy account I made to see if the user's account was deleted but it wasn't. Please can someone shed some light on what I need to do or what I have done wrong.

Here is the cron job in my cPanel

*/5   *   *   *   * /path/to/my/script

I would really appreciate some help.

Here's a nice quick reference.

Quote: "Repeat pattern like /2 for every 2 minutes or /10 for every 10 minutes is not supported by all operating systems. If you try to use it and crontab complains it is probably not supported."

You could try this instead:

5,10,15,20,25,30 * * * * /path/to/my/script

I assume you tested the query in phpMyAdmin to test if it works (or by running the file via the browser).

Some setups require you to specify the php executable with your crontab, like this:

*/5 * * * * php /path/to/my/script

Then, sometimes you need to specify something like the following in your php file:

#!/usr/local/bin/php -q
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.