0

I have a bunch of PHP scripts are run by cron (/etc/crontab) at specific times. The scripts are owned by www-data. However, www-data does not have shell access. In fact, it has "nologin" set as its shell.

I am unsure which user to run the script as. I don't think it's safe to run the script as root - that would give it too much access to things in case anything harmful might ever happen inside those scripts. But I also am not sure if it is safe to give the www-data user shell access.

Anyone that is better informed on the subject that could help me out here?

minitauros
  • 103
  • 4

1 Answers1

1

It is safer to run cron job with the user that own the files in web path.

In order to run cron job shell access is not required. However, if you need it for some reason, you can defile it in environment variable SHELL=/bin/bash in the crontab.

SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 * * * * php test.php
dkokmadis
  • 574
  • 2
  • 9
  • That is what I thought :). The cron jobs were not running for some reason and I thought it was because www-data didn't have shell access, but apparently something else was wrong, as I have made some changes and everything is working now. Thanks! – minitauros Aug 25 '17 at 12:34