/home/havouza/public_html/cron.php: Permission denied

SYSTEM INFORMATION
OS type and version Ubuntu 22.04
Webmin version Latest

I try to run a new cron job but get this error. What can be the problem

/home/havouza/public_html/cron.php: Permission denied

When I change the permissions I get this

/home/havouza/public_html/cron.php: 1: cannot open ?php: No such file
/home/havouza/public_html/cron.php: 2: /aquota.group: Permission denied
/home/havouza/public_html/cron.php: 3: Syntax error: “(” unexpected

That’s a php problem not virtualmin … I assume that the php file does not have a shebang line and is not executable ? If so run the command via php cli like so

/usr/bin/php /home/havouza/public_html/cron.php

a shebang line should be the first line in a php file before <?php and should be similar to this

#!/usr/bin/php -d memory_limit=2048M

hope that helps

Very dangerous running cron jobs in a public area, any reason you trying this, is it a software package?

Not if they are coded correctly in the first place, for example with php, you can detect how php is running (web or cli). So given that you can then reject all web request to the file. If the file is designed to be a cron only script you can run the cron as root, get php to detect the current user executing the file & if it’s not root terminate execution. where is very dangerous in that ?

Agree if they programed correctly, I run WHMCS, they advise to run the cron.php in a non public area.
Its a better safe the sorry situation.

I have written an API in php which includes a file called cron.php, which is coded in the style mentioned above, so far I have not been able to break it, in fact the whole API runs from the command line apart from 1 file which checks the web request for validity, either rejecting the bad request or passing the parameters to the exec call

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.