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
https://forums.phpfreaks.com/topic/218108-chmod-only-cron-jobs-can-run-it/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.