LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   server cron issue? (https://www.linuxquestions.org/questions/linux-newbie-8/server-cron-issue-4175442618/)

gamorgan 12-22-2012 10:44 PM

server cron issue?
 
Hi all

I'm trying to run a couple of simple commands via cpanel scheduler. I have two domains hosted on the same server. The commands run without a hitch on one domain but not the other..... both virtualy identical Word press installation.

Hosting on Linux,so hence my being here.

My attempts to run commands are met with this error log.

#!/usr/bin/perl
use warnings;
use strict;
use CGI;

(my $forward_win_path = ($ENV{PATH_TRANSLATED}||"")) =~ s#\\#/#g;
my ($pwd) = ($ENV{SCRIPT_FILENAME} || $forward_win_path) =~ m#(.*)/[^/]+$#;
my ($user) = $pwd =~ m#^(?://[^/]+?)?/home(?:/sites)?/([^/]+)/#;

undef(%ENV) unless ($ENV{OS}||"")=~m/Windows/;

$ENV{HOME} = "/home/sites/$user";
$ENV{LOGNAME} = $user;
$ENV{SHLVL} = 1;
$ENV{MAILTO} = '';
$ENV{_} = '/bin/nice';
$ENV{PATH} = '/usr/bin:/bin';
$ENV{SHELL} = '/bin/sh';
$ENV{PWD} = $pwd;
$ENV{USER} = $user;

unlink $0;

my $cgi = new CGI;
print $cgi->header();

chomp(my $script_to_run=<DATA>);
chomp(my $script=<DATA>);

if(!-f "$script_to_run") {
print "Can't find '$script_to_run'. Check that you have the correct location.";
exit;
}

print `$script`;
close (DATA) and unlink($0);
__DATA__
/home/sites/grahammorganphotographer.co.uk/make-it.sh
/home/sites/grahammorganphotographer.co.uk/make-it.sh



I can run the commands quite happily from the command line, and all is well.
They will not execute from cpanel for no reason that I can see....They are saved as .sh files in the exact location required, exactly as shown in the log above.

Any ideas...... perhaps an interpretation of the error log?

Many thanks

GM

gamorgan 12-23-2012 12:37 PM

Ideas please? scheduled command that won't run
 
Here is the command in question, very simple, and works fine with another account on the same server.

mysqldump -hlocalhost -uxxxxxxxxxxx -p xxxxxxxx xxxxxxxxxxx | gzip > /home/sites/grahammorganphotographer.co.uk/public_html/xxxxxxxxx/xxxxxxx/xxxxxxxxxxxx.sql.gz


Just can't run it from the scheduler... it sits in exactly the path specified in my cpanel and in the error message.



I'm stumped and can only think it's a server issue that my web host should look at; they just throw it back to me....... so frustrating.




Quote:

Originally Posted by gamorgan (Post 4855266)
Hi all

I'm trying to run a couple of simple commands via cpanel scheduler. I have two domains hosted on the same server. The commands run without a hitch on one domain but not the other..... both virtualy identical Word press installation.

Hosting on Linux,so hence my being here.

My attempts to run commands are met with this error log.

#!/usr/bin/perl
use warnings;
use strict;
use CGI;

(my $forward_win_path = ($ENV{PATH_TRANSLATED}||"")) =~ s#\\#/#g;
my ($pwd) = ($ENV{SCRIPT_FILENAME} || $forward_win_path) =~ m#(.*)/[^/]+$#;
my ($user) = $pwd =~ m#^(?://[^/]+?)?/home(?:/sites)?/([^/]+)/#;

undef(%ENV) unless ($ENV{OS}||"")=~m/Windows/;

$ENV{HOME} = "/home/sites/$user";
$ENV{LOGNAME} = $user;
$ENV{SHLVL} = 1;
$ENV{MAILTO} = '';
$ENV{_} = '/bin/nice';
$ENV{PATH} = '/usr/bin:/bin';
$ENV{SHELL} = '/bin/sh';
$ENV{PWD} = $pwd;
$ENV{USER} = $user;

unlink $0;

my $cgi = new CGI;
print $cgi->header();

chomp(my $script_to_run=<DATA>);
chomp(my $script=<DATA>);

if(!-f "$script_to_run") {
print "Can't find '$script_to_run'. Check that you have the correct location.";
exit;
}

print `$script`;
close (DATA) and unlink($0);
__DATA__
/home/sites/grahammorganphotographer.co.uk/make-it.sh
/home/sites/grahammorganphotographer.co.uk/make-it.sh



I can run the commands quite happily from the command line, and all is well.
They will not execute from cpanel for no reason that I can see....They are saved as .sh files in the exact location required, exactly as shown in the log above.

Any ideas...... perhaps an interpretation of the error log?

Many thanks

GM


gamorgan 12-23-2012 01:46 PM

OK, moved this to the 'Linux Server' forum area.
 
OK, moved this to the 'Linux Server' forum area.

Quote:

Originally Posted by gamorgan (Post 4855595)
Here is the command in question, very simple, and works fine with another account on the same server.

mysqldump -hlocalhost -uxxxxxxxxxxx -p xxxxxxxx xxxxxxxxxxx | gzip > /home/sites/grahammorganphotographer.co.uk/public_html/xxxxxxxxx/xxxxxxx/xxxxxxxxxxxx.sql.gz


Just can't run it from the scheduler... it sits in exactly the path specified in my cpanel and in the error message.



I'm stumped and can only think it's a server issue that my web host should look at; they just throw it back to me....... so frustrating.


colucix 12-24-2012 02:23 AM

Nope. You didn't move, you posted a duplicate... that's different. Please, next time ask a moderator to move the thread for you by reporting your own post (notice the REPORT button in the lower right corner of your posts). Anyway, this one is now closed. Let's see if your question has more luck in the Server forum!


All times are GMT -5. The time now is 08:42 PM.