Cron jobs, PHP and parameters


#1

I’m having a little bit of trouble getting cron jobs to work the way I want them - at the minute, I’ve got a cron job set up to run a script every day at midnight to backup a set of scripts that I’m working on, and it’s working okay. However, there’s a thing I was wondering about…on another system I set up a cron job on, I used a parameter on the command to make sure that people couldn’t run the script via a browser (if($argv[0] == “myParam”)), but I haven’t been able to do so here.

My crontab, as it stands, looks like this:
“0 0 * * * /dh/cgi-system/php.cgi /home/user/domain/backup.php”

I tried just adding another parameter after the path to the script, but that didn’t work very well…at all. The crontab was malformed when I did that, apparently, so I guessed I was on the wrong track.

Does anyone know how I can send a parameter to PHP using this method? Would I have to use the alternative method of running PHP scripts from cron as detailed on the wiki?

Thanks.


#2

The best way to prevent a script from running in the browser is by NOT putting it in your web directory. :wink:

Put the script at: /home/user/bin/
or /home/user/scripts/

Instead of inside your domain.com/ directory. That’ll insure it will never, ever see a browser interface, ever.


yerba# rm -rf /etc
yerba#


#3

…haha. I feel really daft now, that’s…quite a nice, logical solution, isn’t it?

Thanks a lot!