Mobile app version of vmapp.org
Login or Join
Rambettina238

: How can I call a URL as a cron job in Webmin? (Possibly this belongs on stackoverflow, although it's not really a programming issue since the code works when run directly. If it needs to

@Rambettina238

Posted in: #ControlPanel #Cron #Php #Webmin

(Possibly this belongs on stackoverflow, although it's not really a programming issue since the code works when run directly. If it needs to be moved, though, no problem.)

I have a PHP file (which consumers a National Weather Service web service via SOAP, if it matters) that I need to run on a scheduled basis. I'm trying to set up a cron job in Webmin. If I use an absolute path to the file in the Command field, when I run it I get some strange errors:

/var/www/html/mysite.com/test/ndfdXMLclient.php: line 1: ?php: No such file or directory
/var/www/html/mysite.com/test/ndfdXMLclient.php: line 2: //: is a directory
/var/www/html/mysite.com/test/ndfdXMLclient.php: line 3: //DOCUMENTATION: No such file or directory
/var/www/html/mysite.com/test/ndfdXMLclient.php: line 4: //: is a directory
/var/www/html/mysite.com/test/ndfdXMLclient.php: line 5: syntax error near unexpected token `"running client code",'
/var/www/html/mysite.com/test/ndfdXMLclient.php: line 5: `error_log("running client code", 1, "myemail@gmail.com");'


The actual code in my file for those 5 lines looks like this:

<?php
// ***************************************************************************
//DOCUMENTATION FROM WEATHER.GOV ALL STORED IN xmlClientComments.txt
// ***************************************************************************
error_log("running client code", 1, "myemail@gmail.com");


The code runs perfectly fine when I run it directly in my browser, so why doesn't webmin recognize it as code? (The same thing happens if I enter the actual URL in the command field - mysite.com/test/ndfdXMLclient.php.)
I've never worked with webmin before; most of our hosts' cron control panels allow cron jobs to run PHP files like this with no issue. Is there some trick to getting webmin to read php as actual php?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Rambettina238

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kristi941

You probably need to add the hashbang at the top of your script so the server knows where to find PHP to precess the script.

Make sure the path to the PHP executable is correct for your server.

#!/usr/bin/php -q
<?php
// ***************************************************************************
//DOCUMENTATION FROM WEATHER.GOV ALL STORED IN xmlClientComments.txt
// ***************************************************************************
error_log("running client code", 1, "myemail@gmail.com");

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme