Z
Z
zyaleniyeg2015-02-08 12:47:34
linux
zyaleniyeg, 2015-02-08 12:47:34

Reloading mysql from PHP/exec, how?

There was a need to restart mysql
wrote a small PHP script that, under certain conditions, does
exec('service mysqld restart');
the script is hung on cron from under the root to run once a minute
*/1 * * * * /usr/bin/php -f /var/[webpath]/mysql_restart.php >/dev/null 2>&1
and .. nothing - PHP fails to do this, banal
exec('service mysqld status > out.txt');
leads to the fact that "emptiness" is written to the file, but the banal
exec('whoami > out.txt') in the same file, easily writes to out.txt - 'root'
tell me where is the plug?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey, 2015-02-08
@rdifb0

Or maybe this is a hint to you that you do not need to overload mysql (why did you need it)?
Add 2>&1 to redirect errors to a file as well.

P
Puma Thailand, 2015-02-08
@opium

You are most likely not running as root, and not root does not have rights to reboot services.

S
ShamblerR, 2015-02-18
@ShamblerR

you really don't have enough rights to mysql

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question