Back-end automated script

davidshaw89

Free Member
Jan 19, 2008
786
169
Edinburgh
Hi everyone,

I am looking to create a script for the back-end of a website, but I want this to run at set times throughout the day/week/month even when I can't be at a computer.

Does anyone know what this is called? and if I need to use certain programming languages for it?

Basically I want the website to automatically delete records from a MySQL database when they become obselete without any human interaction.

Thanks in advance,
 

davidshaw89

Free Member
Jan 19, 2008
786
169
Edinburgh
Thank you all for the advice.

If I can hopefully get Crontab to execute a simple php script successfully it could mean that I can actually automate a lot more of the processes than initially planned through the night instead of daytime when the server is busy.

Much appreciated
 
Upvote 0

FireFleur

Free Member
Oct 29, 2008
1,881
440
Be careful, it is not CGI which is the Common Gateway Interface used in webservers.

If you have to use PHP and this is something that has been added, it is more aking to running PHP as an application, some call it PHP shell scripting.

The CGI mentioned is sort of the steps to take, but ironically it is without the CGI so don't go placing it in directories that can be accessed via the web, otherwise it becomes potentially accessible via the web.

You create a file and add a shebang line e.g.

#!/usr/bin/php -q
<?php

print "It works!\n";

... code goes here

?>

Then chmod 700 the file.

Then execute it to see it works so

./file.php

Personally I would use something else, but if PHP is your bag then it should be ok.

You will have to include various things to gain access to the DB, and any modules you have been using will have to be introduced - and this is where the CGI idea springs in, there is crossover in how you do it.

I notice the link given doesn't use a shebang, that may not be necessary nowadays, as I say I don't really use this feature of PHP, or PHP much for that matter nowadays :)
 
  • Like
Reactions: davidshaw89
Upvote 0

Latest Articles

Join UK Business Forums for free business advice