Re: Using Cron job.
I have written a script in php which searches through a table and sends
people an email reminders about certain events.
To run the script everyday ( actually twice a day) I guess that I need
to use cronjob ?
Is that a VirtualMin function or Webmin ?
Does anyone know how I go about setting this up ?
Yup! A cron job would handle that well.
And you can certainly do that within Virtualmin.
If you log in as the Virtual Server owner, go into Webmin Modules -> Scheduled Commands, and you can setup a command to run there at what ever interval you require.
OK I have found the Create Cron Job
I have assigned the appropiate user the one that has access to
Now it says “Command” and “Input to command”.
I want tp run a php script file
which is at http://www.expert-world.net/sys/test_01.php
Do I put that url into the Command box ?
You rarely want to use the “input to command” field – in fact, I’d go as far as saying you should probably just ignore that field for now
You can put your command, and all it’s parameters, into the “Command” field.
probably more like:
php -q /home/expert-world.net/public_html/sys/test_01.php
if you want to output whatever the script does you can use:
php -q /home/expert-world.net/public_html/sys/test_01.php >> /home/expert-world.net/public_html/sys/script_log.txt
Depending on whether the cron relies on any of the apache environment variables, you can either use the php commands mentioned already, or you can use the command below to run the script via the url
(this is in the command box btw)
wget -O - http://www.expert-world.net/sys/test_01.php > /dev/null
that will trigger the script, and discard any output that is received, if the script generates a response you want to keep, you can replace /dev/null with the logfile you want to use, and use >> instead of > if you want to have an ongoing log, rather then just the last run