Which user should run my PHP cron job?

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?

0
задан 24 August 2017 в 12:04
1 ответ

Безопаснее запускать задание cron с пользователем, которому принадлежат файлы в веб-пути.

Для запуска задания cron доступ к оболочке не требуется. Однако, если он вам по какой-то причине нужен, вы можете осквернить его в переменной окружения SHELL = / bin / bash в crontab.

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

0 * * * * php test.php
1
ответ дан 4 December 2019 в 16:09

Теги

Похожие вопросы