M
M
Millerish2016-03-25 11:42:36
linux
Millerish, 2016-03-25 11:42:36

How to give cron write and read permissions?

Good afternoon!
Tell me, how to give cron permissions to write / read a file on Debian?
Part of the script where the problem occurs:

if (is_writable($dir_url)) {
mail('[email protected]', 'OK', "mogy zapisat!");
} else {
mail('[email protected]', 'Err', "ne mogy zapisat!");
}
if (is_readable($dir_url)) {
mail('[email protected]', 'OK', "mogy prochitat'!");
} else {
mail('[email protected]', 'Err', "ne mogy prochitat'!");
}

If I run through the browser (http) - everything is ok. If I run it via cron - ne mogy zapisat! and ne mogy prochitat'!.
Cron tried like this:
/usr/bin/wget -O - -q -t 1 XXX/xibo-alarm/index.php?name=27&url=../../../xibo... >/dev/null 2>&1

so
curl -s XXX/xibo-alarm/index.php?name=27&url=../../../xibo... >/dev/null 2>&1

so
wget XXX.XXX.XXX/vi-test/date-inspection/index.php >/dev/null 2>&1

How to fix?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Evgenievich, 2016-03-25
@Millerish

crontab executes tasks on behalf of the user under which these tasks were given. And a web server, for example apache, already has its own user (for example www-data), and this user already has its own rights and group. So you need to look at the group and user rights under which you run cron tasks.

A
Azazel PW, 2016-03-25
@azazelpw

Add the cron user to a group that has read and write access to the folder.
This can be done with usermod -G

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question