在特定日期运行脚本?

I want to run a php script on christmas that will email my family and friends merry christmas while I am out of town and un-able to contact them.

The way I just set it up was I have a cron run the script every day, and then the script checks to see if the date is Dec 25th. If it is then the script sends the emails out.

Is there a more elegant way to do this. Or a way to have linux just send run the script on the 25th rather than checking everyday. I know it's not that big of a deal, but still just for the sake of knowing.

You can fire cron on a particular date only, if you like. This'll fire at 8 AM on Christmas.

0 8 25 12 * /path/to/script

This day will echo happy Xmas on Xmas day (the 25th)

<?php

date_default_timezone_set('America/Montevideo');


$exp_date = "2010-12-25";
$todays_date = date("Y-m-d");

$today = strtotime($todays_date);
$expiration_date = strtotime($exp_date);

if ($expiration_date == $today) {

echo "happy christmas"; #you can put your Xmas script here

} else {

echo "not every day can bechristmas";

}

?>

Is this what you were looking for?

BTW:

Yot Xmas eail can be send with mail() with PHP, something like:

$to      = 'myfamily@example.com';
$subject = 'Merry Xmas';
$message = 'Merry Xmas and a happy new year';
$headers = 'From: webmaster@example.com' . "
" .
    'Reply-To: webmaster@example.com' . "
" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);