LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 12-22-2012, 11:44 PM   #1
gamorgan
LQ Newbie
 
Registered: Dec 2010
Posts: 12

Rep: Reputation: 0
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
 
Old 12-23-2012, 01:37 PM   #2
gamorgan
LQ Newbie
 
Registered: Dec 2010
Posts: 12

Original Poster
Rep: Reputation: 0
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 View Post
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

Last edited by gamorgan; 12-23-2012 at 01:39 PM.
 
Old 12-23-2012, 02:46 PM   #3
gamorgan
LQ Newbie
 
Registered: Dec 2010
Posts: 12

Original Poster
Rep: Reputation: 0
OK, moved this to the 'Linux Server' forum area.

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

Quote:
Originally Posted by gamorgan View Post
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.
 
Old 12-24-2012, 03:23 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
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!
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron issue jameshurrell Linux - General 4 10-23-2012 04:54 PM
[SOLVED] cron issue dushyantgohil Linux - Server 9 10-04-2012 06:55 AM
Issue in running shell script using cron job in Unix server. Mundlamuri Programming 7 07-12-2011 12:37 PM
cron issue props666999 Debian 1 08-31-2007 12:35 PM
cron issue abdul_zu Linux - Newbie 8 08-01-2005 12:39 AM


All times are GMT -5. The time now is 01:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration