Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a file queue.php which I have set up as a cron job. I don't want users to be able to access it. How can I do this?

share|improve this question
    
are you running the cron job via HTTP or from shell? –  Andre Lackmann Apr 12 '12 at 21:47

2 Answers 2

up vote 4 down vote accepted

Straight file permissions should do the trick. Just make the file readable by the user that cron runs as and not by anyone else.

chmod [restricted-user]:[restricted-group] 640 should do it.

share|improve this answer
    
How can I do this via FTP access? –  slimetree Apr 12 '12 at 19:11
    
@JonathanLingle Depends on the server and client, but I would say you've got a good chance of being able to do it. Log in with ftp and type help to see what response you get. chmod over ftp is common. –  Wesley Apr 12 '12 at 19:12
    
Thanks for the help! Here's an image showing what I'm doing. Unfortunately, the user is still able to run queue.php. What am I doing wrong? –  slimetree Apr 12 '12 at 19:20
    
@JonathanLingle What user is the web server running as? –  Wesley Apr 12 '12 at 19:21
    
What I suspect is that you are on a shared hosting account and the web server is running as your user account. If that's the case, you only have access to one user account and group, so you'll probably need to use some kind of .htaccess restriction to keep people from viewing it on any device except localhost. –  Wesley Apr 12 '12 at 19:24

Depending on external dependencies I usually do this by restricting the permissions on the file on the Linux side and putting the file itself outside of the public web root to guarantee it cannot be accessed by anyone except the server.

If for some reason the file cannot exist outside the web root (perhaps due to an openbasedir restriction or some kind of pathing issue) the straight unix permissions as suggested by Wesley David would do the trick.

You could also use .htaccess or even php itself to restrict how the script can be executed.

share|improve this answer
    
+1 for being outside web root. –  ceejayoz Apr 12 '12 at 19:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.