10 Years
Discussion Span
Last Post by Ajaypal_1

you need to set up a cron job (or crontab), make sure your webserver allows you to run a cron job, if so look in your control panel for how to set it up, if it's not in there then log in via SSH and type "man cron" to get the man pages. Crons can be difficult to set up so try searching the web for some tutorials or asking in the linux forums for how to set up this particular cron job

Id like to generate an automatic email at certain times of the week from my website to certain users. i.e at 12.30 on wednesday id like an email reminder sent to user example@example.com. Can anyone point me in the right direction :?:


Sorry i didnt mention that the website sits on a windows platform machine.


Sorry i didnt mention that the website sits on a windows platform machine.

The windows scheduled tasks manager works the same as cron. You can set up the task to run your php script.

If you want a purely web based solution take a look at this article in my blog: http://fijiwebdesign.com/content/view/86/77/

You could use the method mentioned there, with a bit of php like:

pseudo code:

$query = "select from my_tasks where time < time() and complete = false".
$uncomplete_tasks = query($query);

foreach ( $uncomplete_tasks as $task) {

// carry out task
// for example if you list php scripts to run.. do something like
exec("wget http://example.com/$task.php");
// then update the database, task success, or fail etc.


I checked out your exec and html solutions, but neither one fit my needs.
I want to implement a distributed script that will send a BirthDay Greeting, automatically, at specific times of the day (midnight, of course). As described here, basically, this is the definition of a cronjob. But you can't distribute a software that will automatically setup a cronjob for the enduser's website, so it's out of discution.
Of course, it can be purely programmed in php/mysql/javascript, if we'd be sure there would be at least one visitor on a specific page that, by loading, would trigger the script for sending the email/emails at that moment in time.
Unfortunatelly, this is only a matter of pure luck!

I would consider the worst case, no one is visiting the website for one entire week (hypothetically).

How can we tell the website hosting server to run a script, as the cronjobs do, without using the cron system?

Is there any alternative to that? (javascript was the first thing that came to my mind, being a server-side language, but i'm not so sure it would work without a client browser triggering...)

What are your ideas/expertise about this? Could it be done? (on any linux/mac/windows servers, of course).
Thanks for your tutorials.

Edited by ciprianmp: typos


If you don't have cron, then you need a client process to trigger.
You could have a php / javascript reloading page which at a certain time processes the list. You would need a browser running somewhere. This is not necessarily a bad thing as it could act as a status page too.
If you are interested in pursuing this further, I'd be happy to assist you.

Edited by Ezzaral: Snipped email. Please keep it on site.


I'm not sure if this would work, but try


$now = time();
$original_tz = $_ENV["TZ"];

if (Date("h:m", $now) == 12:30); 
mail(me@example.com, "subject", "MESSAGE");


Anybody help me ?

I need a php script that will run automatically every day on Morning 09:00 O'clock. But my script not working. My script.


$now = date("h:i");
$base = '09:00';
$to      = 'test@mydomain.com';
$subject = 'My Subject';
$message = 'Hello';
$headers = 'From: test@mydomain.com' . "\r\n" .
    'Reply-To: test@mydomain.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if ($now == $base) {
    mail($to, $subject, $message, $headers);

Thanks in advance!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.