Run the script on a specific date?

I want to run a php script for Christmas, which will email my family and friends a happy Christmas, until I leave and can not contact them.

As I just installed this, I ran a cron script every day, and then the script checks to see if the date matches December 25th. If this is the case then the script sends emails.

Is there a more elegant way to do this. Or a way to get linux to simply send the run script to the 25th rather than checking every day. I know this is not such a big deal, but still just for the sake of knowledge.

+3
source share
2 answers

cron , . 8 .

0 8 25 12 * /path/to/script
+8

Xmas Xmas (25)

<?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";

}

?>

, ?

BTW:

Yot Xmas eail mail() PHP, - :

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

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

Source: https://habr.com/ru/post/1779040/


All Articles