I am trying to setup a program in Flash using PHP and MySQL. When I came to a portion of it that needs to be automatically updated with or without the end user being logged on I was told I needed to use a cronjob.
Now to be honest I have never touched this is my life. I found the information about setting up a cronjob and now I need to setup a .pl script. Basically the this script would need to update the credits field in a table every 15 minutes based on the end users account field.
If someone could point me in the right direction as to where I might find something like this or how to write it, that would be much appreciated! Thanks!
sure. cronjobs are set up with crontab -e -u username where username is the user the cron should be executed under. format is: m h dom mon dow command so, let's say you want to run your script every 30 minutes, just put in a line 0,30 * * * * /var/www/myscripts/update-credits.pl
as for the perl-script itself, you basically copy it to the server into the cgi-bin, make sure you used unix-linebreaks and chmod it to 755. but you don't necessarily need a perl-script for a cronjob, you can also use a php-script and call it using lynx or wget. that'll invoke the script and you can do your updates.
755 is for a CGI script. For a script run by a cronjob 700 (or lower) is advisable. It should also not be put in the public cgi-bin if possible. It should be in a folder that is not web accessible, above the root if at all possible. If that is not possible the cgi-bin should be the last resort but don't chmod to 755 unless the script will not run with lower permissions.