I created a Linux Cron Job like:
0 0 * * * home/www/wp-content/themes/my_theme/functions.php
The file wp-content/themes/my_theme/functions.php has the function I need to call from the cron job: do_something().
As you can see the command is: home/www/wp-content/themes/my_theme/functions.php
is wrong, since I need to specify my function: do_something().
My question is: how do chage the job command to execute the function do_something().
(1) Do not call functions.php file directly for cron job if you have wordpress specific function to use but setup wordpress environment first with two commands I mentioned in the previous question you had posted.
(2) If your do_something() function is not for any wordpress related task, just copy that function and use it in your cron file, say mycron.php
(3) You had asked where to put this suggested code. Put suggested code at the top of your mycron.php file.
what you're missing is the
PHP
path, so this should work like this:cron-functions.php
In case you are wondering you can also pass in arguments or function calls via cron like:
And that should be pretty much it, some times you may have issues with user permissions to run cron or PHP CLI processes if that is the case and this does not work just let us know so we can help you.
Good luck.