Jump to content

chmod - only cron jobs can run it


corbeeresearch

Recommended Posts

Hi, is it possible to make a php script only executable by cpanel's cron job and not by anyone else. I was thinking chmod, but what's the correct chmod to make it only executable by server and not just by anyone, or does anyone know how to prevent a visitor(hacker) from running a script that is designed to be only used by cron?

 

Thanks

Link to comment
Share on other sites

Basic Unix permissions come in a three digit octet sequence (ex. 755).  Where the first digit relates to the owner permissions, the second digit to the group permissions and the third to everyone else. Pretty good explanation here.  The situation is dependant on your group memberships and cron's group memberships so I'll leave you with a non permission based solution.

 

$_ENV will contain some different variables from a command line execution versus a website/apache execution.  I'd just detect one or more of those variables and execute my script or log/exit otherwise.  I'll leave it up to you to find those variables.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.