Posts: 81
Threads: 16
Joined: Apr 2015
Reputation:
0
Sex: Undisclosed
Thanks: 4
Given 9 thank(s) in 7 post(s)
Cron Manager doesn't appear to be working in Sentora v1.0.0
04-12-2015, 03:53 PM
So I'm new to Sentora and the last piece of the puzzle I am trying to sort out is getting Cron to run my Drupal update scripts. It's pretty straightforward and I never had issues with cpanel and doing this.
In my website root folders (Drupal), I have a file cron.php which I want to run daily. I have added it to the Sentora Cron Manager but it doesn't seem to actually run the cron.php.
Initially I put in the path as follows:
/sitename_com/cron.php
as instructed on the page with these directions:
"example: /folder/task.php
Note 1 : Script path is relative to your sentora-user root directory:
/var/sentora/hostdata/zadmin/public_html/
Note 2 : Each file access in your script must use absolute directory path as above."
however, it doesn't seem to work, as my site shows that cron has not been run. So then I looked into the file here: /var/spool/cron/crontabs
This is where Sentora puts the www-data file which has all the cron jobs listed. I noticed that there was an extra "/" being put inline.
So the last line of the cron job showed something like this:
/var/sentora/hostdata/zadmin/public_html//mywebsite_com/cron.php
So I think that's wrong. But I followed the directions exactly as told. Anyway, I went back and deleted that cron job from the cron manager and this time, I added the URL as follows:
sitename_com/cron.php
* note I omitted the forward slash at the start of this line.
Now looking at the file at /var/spool/cron/crontabs
it shows the path without the extra forward slash:
/var/sentora/hostdata/zadmin/public_html/mywebsite_com/cron.php
The entire line looks like this:
* * * * * 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, exec" -d open_basedir="/var/sentora/hostdata/zadmin/:/var/sentora/temp/" /var/sentora/hostdata/zadmin/public_html/mysite_com/cron.php
# END CRON ID: 8
However, cron is still not running my cron.php file as I can see that cron has not been run when looking at the Drupal status pages. Can someone advise what is going on and what I'm doing wrong? Obviously I can just add a cron task myself in the terminal, but I could prefer to use Sentora to do this. This seems like a bug, but then I'm sure everyone would know it if it truly was a bug. Any ideas???
Posts: 81
Threads: 16
Joined: Apr 2015
Reputation:
0
Sex: Undisclosed
Thanks: 4
Given 9 thank(s) in 7 post(s)
RE: Cron Manager doesn't appear to be working in Sentora v1.0.0
04-12-2015, 07:05 PM
I forgot to mention...so I have confirmed that cron.php runs and completes successfully if I just copy and paste the php code that is auto created by Sentora...i.e.
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, exec" -d open_basedir="/var/sentora/hostdata/zadmin/:/var/sentora/temp/" /var/sentora/hostdata/zadmin/public_html/mysite_com/cron.php
So that works if I manually paste it into the terminal. So why wouldn't this run succesfully through Sentora and the Cron manager.
Looking at syslog log (tail /var/log/syslog) file I can see this (I just changed a few things to conceal the site's identity):
Apr 12 18:02:01 panel CRON[14857]: (www-data) CMD (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, exec" -d open_basedir="/var/sentora/hostdata/zadmin/:/var/sentora/temp/" /var/sentora/hostdata/zadmin/public_html/sitename_com/cron.php)
Apr 12 18:02:01 panel postfix/pickup[14406]: B3A53142D2C: uid=33 from=<www-data>
Apr 12 18:02:01 panel postfix/cleanup[14500]: B3A53142D2C: message-id=<20150412090201.B3A53142D2C@panel.sitename.com>
Apr 12 18:02:01 panel postfix/qmgr[1062]: B3A53142D2C: from=<www-data@sitename.com>, size=1793, nrcpt=1 (queue active)
Apr 12 18:02:01 panel postfix/qmgr[1062]: warning: connect to transport private/retry: Connection refused
Apr 12 18:02:01 panel postfix/qmgr[1062]: B3A53142D2C: to=<www-data@panel.sitename.com>, orig_to=<www-data>, relay=none, delay=0.01, delays=0.01/0/0/0, dsn=4.3.0, status=deferred (mail transport unavailable)
So as you can see the syslog file, it's definitely running that php line which should run the cron.php file. However, it's not being run as there is no record of cron being run on the Drupal site and it shows that the cron job has not been run.
Any ideas why it's not working automatically with the cron job?
Posts: 4 ,002
Threads: 193
Joined: Jul 2014
Reputation:
83
Sex: Undisclosed
Thanks: 72
Given 435 thank(s) in 395 post(s)
RE: Cron Manager doesn't appear to be working in Sentora v1.0.0
04-12-2015, 08:23 PM
There is a report being sent by email and seem your SMTP port is closed/down.
M B
Posts: 81
Threads: 16
Joined: Apr 2015
Reputation:
0
Sex: Undisclosed
Thanks: 4
Given 9 thank(s) in 7 post(s)
RE: Cron Manager doesn't appear to be working in Sentora v1.0.0
04-12-2015, 09:43 PM
Hi Me.B...I think you are commenting on the part of the log file that is unrelated to this topic. I just posted a few lines after the CRON entry in the log to show there was nothing else. So please ignore the mail related error stuff as it's unrelated.
Posts: 81
Threads: 16
Joined: Apr 2015
Reputation:
0
Sex: Undisclosed
Thanks: 4
Given 9 thank(s) in 7 post(s)
RE: Cron Manager doesn't appear to be working in Sentora v1.0.0
04-12-2015, 09:48 PM
So I noticed something else here which may be related to my issue.
I noticed that when I would copy and paste the line of code in cron:
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, exec" -d open_basedir="/var/sentora/hostdata/zadmin/:/var/sentora/temp/" /var/sentora/hostdata/zadmin/public_html/mysite_com/cron.php
while I was inside the directory /var/sentora/hostdata/zadmin/public_html/mysite_com/ it would work just fine.
However if I stepped out of that directory into let's say " /home" and then ran the same line in the terminal it would actually give an error and not run. So it seems this may be my issue. Although I don't understand why it would be an issue as the path is still there, but I think I am getting closer to understanding this. Can someone comment on this?
Here is what happens when I run this line in the terminal OUTSIDE of the directory of the root directory of this website.
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, exec" -d open_basedir="/var/sentora/hostdata/zadmin/:/var/sentora/temp/" /var/sentora/hostdata/zadmin/public_html/mysite_com/cron.php
PHP Warning: include_once(): open_basedir restriction in effect. File(./includes/bootstrap.inc) is not within the allowed path(s): (/var/sentora/hostdata/zadmin/:/var/sentora/temp/) in /var/sentora/hostdata/zadmin/public_html/mysite_com/cron.php on line 8
PHP Warning: include_once(./includes/bootstrap.inc): failed to open stream: Operation not permitted in /var/sentora/hostdata/zadmin/public_html/mysite_com/cron.php on line 8
PHP Warning: include_once(): Failed opening './includes/bootstrap.inc' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /var/sentora/hostdata/zadmin/public_html/mysite_com/cron.php on line 8
PHP Fatal error: Call to undefined function drupal_bootstrap() in /var/sentora/hostdata/zadmin/public_html/mysite_com/cron.php on line 9
Posts: 4 ,002
Threads: 193
Joined: Jul 2014
Reputation:
83
Sex: Undisclosed
Thanks: 72
Given 435 thank(s) in 395 post(s)
RE: Cron Manager doesn't appear to be working in Sentora v1.0.0
04-12-2015, 10:30 PM
open_basedir restriction in effect. File(./includes/bootstrap.inc)
I think the relative path is the issue. I think this cron was not designed to run in CLI using apache user but more like CPANEL with client user (jailed in own home directory).
Solution would be to setup a manual a cron in linux that will CURL or WGET the file as it will be safe too. I've been thinking since a while we should more offer CURL/WGET cron than CLI cron.
M B
Posts: 81
Threads: 16
Joined: Apr 2015
Reputation:
0
Sex: Undisclosed
Thanks: 4
Given 9 thank(s) in 7 post(s)
RE: Cron Manager doesn't appear to be working in Sentora v1.0.0
04-13-2015, 12:37 AM
Ah...THANK YOU! This explains things. Ahhh, I was pulling my hair out trying to figure this out. And yes, I think the cron manager could definitely be improved by offering CURL/WGET functionality as well as the ability to specific the cron run times. Currently you have no way to specific the time of day to run the job. Also I have several websites on this server, so I like to space out the Drupal Cron jobs as they are somewhat CPU intensive for some of my websites, so I don't want them all running at the same time.
But I was trying to stick with using the control panel to do all tasks for this web server, but it seems it's not suitable for my needs.
Thank you for explaining and pointing me in the right direction.
For anyone that comes across this thread, I thought I would post how I ended up solving this in the end. Here is what I did.
1.) First remove all the Cron tasks I added to Cron manager from Sentora's control panel, no need to have them in there, as they won't work.
2.) While logged in as root into my web server I ran:
# crontab -e
3.) now the crontab file for root is open I added the following line to the end of the file:
0 2 * * * wget -O - -q -t 1 http://www.mysite.com/cron.php
4.) Save the file and now you're done.
Change the first 5 characters to suit your needs. This is setup to run every day of the year at 2am.
You can probably use Curl for even simplier code.
0 2 * * * curl -s http://www.mysite.com/cron.php
If you want to make sure it's working you can change the setting to * * * * * so that it runs every minute.
Then run
# tail -f /var/log/syslog | grep CRON
this will show you realtime results of what's being added to the log file. You should see your cron job running and your Drupal site should show that cron was refreshed within the last minute everytime you refresh the status page within Drupal.
Hope this helps someone!
Posts: 5
Threads: 0
Joined: May 2015
Reputation:
0
Thanks: 0
Given 0 thank(s) in 0 post(s)
RE: Cron Manager doesn't appear to be working in Sentora v1.0.0
05-11-2015, 06:18 PM
You can use this useful drupal module to create cron: https://wordpress.org/plugins/easycron/.
Posts: 525
Threads: 23
Joined: Mar 2015
Reputation:
26
Sex: Male
Thanks: 139
Given 104 thank(s) in 87 post(s)
RE: Cron Manager doesn't appear to be working in Sentora v1.0.0
05-11-2015, 06:31 PM
(05-11-2015, 06:18 PM)Lane Wrote: You can use this useful drupal module to create cron: https://wordpress.org/plugins/easycron/.
I think thats a WordPress Module
Posts: 5
Threads: 0
Joined: May 2015
Reputation:
0
Thanks: 0
Given 0 thank(s) in 0 post(s)
RE: Cron Manager doesn't appear to be working in Sentora v1.0.0
05-11-2015, 06:41 PM
(05-11-2015, 06:31 PM)apinto Wrote: (05-11-2015, 06:18 PM)Lane Wrote: You can use this useful drupal module to create cron: https://wordpress.org/plugins/easycron/.
I think thats a WordPress Module
Sorry, it is https://drupal.org/project/EasyCron.
|