Welcome Guest, Not a member yet? Register   Sign In
Running Cron Safely
#1

[eluser]Glen Swinfield[/eluser]
There seems to be bits and pieces scattered all over the forums/wiki regarding running CI with CRON. The main problems I have found with the solutions are: preventing public user access and using wget/curl etc.

So here's how I did it. It's quite simple.

1. Clone your index.php file and call it, for example cronindex.php
2. Add these lines to the top of the file:

Code:
$_SERVER['REQUEST_URI'] = '/cronindex.php/controller/action/';
$_SERVER['PATH_INFO'] = '/controller/action/';

3. SSH in as root and chmod cronindex.php and your controller (assuming it's only purpose is to be run as a CRON job) like so -
Code:
chmod 0700 cronindex.php
- this allows read, write and execute commands to the owner only. then change the owner and group to root:
Code:
chown root.root cronindex.php

4. Add your cron job to the root cron file.

Now the root user is executing the cronindex.php script and controller. Permission is denied to any other group/user so it is secure.

Different server setups could cause problems. You could also create a different user to prevent using root. It is up to you.

Also, I don't use these forums that often so if anyone thinks this message would be better of elsewhere please move it.


Messages In This Thread
Running Cron Safely - by El Forum - 08-01-2008, 06:12 AM
Running Cron Safely - by El Forum - 08-01-2008, 06:28 AM
Running Cron Safely - by El Forum - 08-02-2008, 12:45 AM
Running Cron Safely - by El Forum - 08-02-2008, 03:54 AM
Running Cron Safely - by El Forum - 08-02-2008, 01:09 PM
Running Cron Safely - by El Forum - 08-02-2008, 05:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB