2

The Setup

I'm running a webserver with CentOS 7.1 x64, Sentora, and suhosin module preinstalled.

I need to trigger a PHP script which does this (among other things)

echo exec('mysqldump -u'.USER.' -p'.PASSWORD.' '.DATABASE.' | gzip > '.$fileName.'.sql.gz');

In order to be able to do that, I have removed the exec from suhosin's blacklist, both via the Sentora admin panel, and by removing exec from the list of blacklisted commands in /etc/sentora/panel/modules/cron/code/controller.ext.php.

As stated on the official site, I've ensured that the owner of both /var/spool/cron and var/spool/cron/apache is apache, and that the permissions are correct (770 and 660, respectively)

The Problem

When I create a new cron job, by using Sentora's Cron Manager, the cron is not doing what it's supposed to (dumping and zipping the database), even though it's triggering the PHP script. I can confirm that the script has no issues, since it does what it's supposed to do when I activate it manually (via browser).

I can also verify that the cron is running - crontab -u apache -l returns:

#################################################################################
# CRONTAB FOR SENTORA CRON MANAGER MODULE
# Module Developed by Bobby Allen, 17/12/2009
# File automatically generated by Sentora 1.0.3
#################################################################################
# NEVER MANUALLY REMOVE OR EDIT ANY OF THE CRON ENTRIES FROM THIS FILE,
#  -> USE SENTORA INSTEAD! (Menu -> Advanced -> Cron Manager)
#################################################################################
# CRON ID: 6
* * * * * php -d suhosin.executor.func.blacklist="passthru, show_source, shell_exec,
system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status,
proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid,
posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg"
-d open_basedir="/var/sentora/hostdata/zadmin/:/var/sentora/temp/"
/var/sentora/hostdata/zadmin/public_html/my_subdomain/cron/cron.php

What am I doing wrong? If it's of any relevance, I'm doing all of this for a subdomain.

  • 1
    If you run the command but not as a cron job, does it work as expected? – Steve May 29 '17 at 21:59
  • 1
    @Steve It does - there's a database dump at the specified location, and the content is as expected. – FiddlingAway May 30 '17 at 7:30
  • 1
    Make sure that the cron user matches the owner of the file. – Steve May 30 '17 at 8:22
  • @Steve The owner of the file was root, while the cron user was apache. I've created a group with both the users (root and apache) set as members, and given ownership of cron.php to the group. However, that still doesn't work as I'd hoped it would (no db dump). Is there anything else I should be doing / checking? – FiddlingAway May 30 '17 at 8:57
  • 1
    go back to basics...instead of using a group, give ownership of the file to whichever user is running the cron job – Steve May 31 '17 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.