I know that WordPress has a faux cron that is called like so when a user visits the page.
register_activation_hook(__FILE__, 'my_activation');
add_action('my_hourly_event', 'do_this_hourly');
function my_activation() {
wp_schedule_event(time(), 'hourly', 'my_hourly_event');
}
function do_this_hourly() {
// do something every hour
}
I want to use linux cron like so:
*/5 * * * * * /usr/local/bin/php/ /Path/to/file
The problem is that if that file is like this:
<?php
function do_something() {
echo 'Hello World';
}
do_something();
Do something function is called every time I reload the page. What I need is a way to specify with linux cron so that do_something() is only called when it is time to run cron. So the file should just have the function definition of do_something() it shouldn't call the function directly.
<?php
function do_something() {
echo 'Hello World';
}