Forum Moderators: coopster
I must to run a script in a scheduled basis: daily.
No problem, I call through cronjob a file including something like this:
wget --delete-after [localhost...] > /dev/null &
I have used it before. But now is very important ensures that this script do not be run from a browser, but only by cron.
Any idea?
Another approach is find some way to ensures that the script is running once at a day. No more no less.
Thanks.-
There may be a better PHP-ish way to prevent this, but overall this should work.
Yes, I did tried the recognition of the user and I am not sure of the results. I did the test with exec("whoami") (storing value with wp:update_site_option()) while running through cron, but then I realized of another problems. And I forgot check the results.
I have a private directory /private_path/cron.php (700)
and run cron like me (nomikos) not root.
* * * * * /usr/bin/wget -q -t 1 --delete-after [localhost.localdomain...]
Anyway, I must go out now. Thanks again rocknbil. I will succed! And show it here.
Bye.-
"08,38 * * * *"
>> * * * * * was only as example.
As I said g1smd, I run a WP script. Finally I did it like this:
if ($_GET['delivery_now'])
{
# only run from local enviroment
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'])
{
die('Invalid Request');
}
$time = time();
$time = date('H:i:s:n:j:Y', $time);
$time = explode(':', $time);
$today_delivery = mktime(0, 0, 0, $time[3], $time[4], $time[5]);# only one delivery for day
if ($today_delivery == get_site_option('celebrations_last_delivery'))
{
die('Delivery Already Sent');
}update_site_option('celebrations_last_delivery', $today_delivery);
# OK, run it
daily_function();
}Question:
You say that it is possible:
* * * * * /usr/bin/php /var/www/html/wpmu/index.php?delivery_now=1
and if it not accept QUERY_STRING, at least:
* * * * * /usr/bin/php /var/www/html/wpmu/delivery_now.php
where delivery_now.php being:
header('location: http : //localhost.localdomain/wpmu/index.php?delivery_now=1');
If it is, believe me, I will spend some time experimenting.