Cron job not running in private folder

Avatar
  • updated
  • Answered

Hi, I have cron job to run a script located in private folder (one level above public_html), at scheduled time, it doens't execute. If I include that same script in a php file in public_html and run that via www...link, it does execute, any thoughts?

Pinned replies
Avatar
johnpaulb-imhs1
  • Answer
Hello, Thank you for contacting us about a Cron job not running. I first recommend confirming if the cron ran successfully, this will help determine if the cron, or the script is failing. Next, I would verify the paths to your script, to confirm they are correct. If your problems persist we are happy to help, but will need some additional information, such as a link or example of the script you are running. Let us know if you have any further questions. Thank you, John-Paul
Avatar
hamidch

If your cron job isn't working in a private folder, it could be due to permission, path, or environment variable issues. Ensure the cron job has permission to execute the script, verify the correct script path, and address any missing environment variables. If problems persist, test running the job from the command line and consider using a cron monitoring service.

Additionally, your script might run in a public_html PHP file because of user permissions – scripts run as the web server user in that context. If the private folder isn't writable by the cron user but is by the web server user, you can make the folder writable by the cron user or use a cron wrapper script to execute it with web server user permissions.

Avatar
johnpaulb-imhs1
  • Answer
Hello, Thank you for contacting us about a Cron job not running. I first recommend confirming if the cron ran successfully, this will help determine if the cron, or the script is failing. Next, I would verify the paths to your script, to confirm they are correct. If your problems persist we are happy to help, but will need some additional information, such as a link or example of the script you are running. Let us know if you have any further questions. Thank you, John-Paul