I have a php script whose name is XYZ.php. When I load that file in browser it executes a form every 5 seconds automatically. I want cron to run this script every hour and I don’t have any problem in setting up cron job in cpanel but I don’t know how to write php codes in XYZ.php file to work with cron.
In my php file there is one form which executes random name from database every hour and submit it to database once again.
So in form there is only one field i.e name of users which needs to be run from cron.
Please guide how can I do that. If I can open that file for 30 seconds using cron then it will do the work I am looking for.
Edit:
This is my form javascript will automatically submit it in 5 seconds so how to execute this script from cron
<form name="form1" method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<input name="lastlogin" type="text" id="lastlogin" value="<?php echo (time()); ?>" size="40" />
<input type="submit" name="Submit" value="submit" />
</form>
cron is a tool designed to execute command line programs. You appear to have a JavaScript-based web application: you simply can’t use that. While you’d be able to retrieve the page using a command line web browser, the dynamic part would not be executed.
The obvious answer is to write a command line PHP script. There’s a full chapter about it in the PHP manual: Using PHP from the command line. I recommend this section: