Welcome to WebmasterWorld Guest from 18.104.22.168
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.
Another approach is find some way to ensures that the script is running once at a day. No more no less.
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.
08,38 * * * * /usr/bin/php /var/www/example.com/autoscripts/script7version5.php >> /home/username/logfiles/script7.log
I never run scripts on the quarters. Think about shared-server load.
"08,38 * * * *"
>> * * * * * was only as example.
As I said g1smd, I run a WP script. Finally I did it like this:
# only run from local enviroment
if ($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'])
$time = time();
$time = date('H:i:s:n:j:Y', $time);
$time = explode(':', $time);
$today_delivery = mktime(0, 0, 0, $time, $time, $time);
# only one delivery for day
if ($today_delivery == get_site_option('celebrations_last_delivery'))
die('Delivery Already Sent');
# OK, run it
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.