• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Scheduled Tasks not Working

KrisScott

Basic Pleskian
Version Parallels Plesk Panel v10.4.4_build1013111102.18 os_CentOS 6
OS Linux 2.6.32-220.4.2.el6.x86_64


I have a perl script.
It works through cgi-bin of the domain, e.g. mydomain.com/cgi-bin/script.pl
It works through command line via ssh /usr/bin/perl /var/www/vhosts/mydomain.com/cgi-bin/script.pl

It fails when set as a scheduled task from plesk panel using path /usr/bin/perl /var/www/vhosts/mydomain.com/cgi-bin/script.pl

I get this error in my email:
-: /usr/bin/perl: No such file or directory

Any suggestions/help is very much appreciated.

Thanks,
Kris
 
Thanks burnleyvic

I had found that article a couple hours back.
Unfortunately i don't think it is to do with ascii characters lf/cr.
The script was downloaded from my other server that is running the exact same plesk and centos versions. It works there from cron. Uploaded in binary to new server and it works except when executed by cron.

To test this further I wrote a simple script to just print "this is a test" and set that as a cron also. It failed with the same error message but executes fine from cgi.

The only difference is that one server is an AMD opteron and the other is a XEON. Everything else is the same.

I'll give this another hour of my time and if it isn't resolved I think its best to reinstall from a different mirror choosing something other than Plesk. I'm a bit fedup with Plesk since version 10 arrived. Nothing but problems.
 
Kris, is PATH correctly set by cron? Try to run a bash script instead of the perl one, perhaps displaying the output of 'stat /usr/bin/perl' shell command.
You may also want to check if Plesk has configured the chroot environment correctly for that account. Is /usr/bin/perl available in the chroot?
 
Never done anything with bash so have no idea what you are asking. But thanks for your help. I'll have to learn a bit before I can try what you say. Just wish Plesk worked 'out of the box' instead of having to muck around with it to get it going.

Is there a log file somewhere that I can view cron errors?
 
Last edited:
My workaround - leave crons not working on this server and trigger the scripts from the cron on a working server using LWP.

Not the best solution by far.
 
Kris, create a file called test.sh with the following content and make it executable:

#!/bin/bash

echo $PATH >> /tmp/test.out
stat /usr/bin/perl >> /tmp/test.out

Then configure a cron job to run it the same way you'd do for the Perl script.
Cron errors are usually emailed to root. If you've set up an alias to collect the email to root you should see emails generated by the failed cron jobs.
 
I don't understand what you did. Did you use the shell script instead of the perl one? If you remove any existing /tmp/test.out and run the shell script from cron, what's in that /tmp/test.out file?
 
I put the script in two different folders.

First folder is /usr/local/bin which is in $PATH
A cron with path /usr/local/bin/test.sh didn't create an outfile but sent me the email message that the directory/file wasn't found.
If I open a terminal, and then bash /usr/local/bin/test.sh I get an out file with content....
File: `/usr/bin/perl'
Size: 6912 Blocks: 16 IO Block: 4096 regular file
Device: 803h/2051d Inode: 15469221 Links: 2
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2011-11-06 01:40:14.000000000 +0100
Modify: 2011-11-06 01:40:14.000000000 +0100
Change: 2012-02-22 19:00:19.540964083 +0100

Second folder that I place test.sh is the cgi-bin folder where the scripts are that I was trying to cron.
A cron for /var/www/vhosts/mydomain.com/cgi-bin/test.sh didn't produce an outfile but sent an error email.
Again, if I open a terminal and use bash /path to test.sh, it then produces the test.out file with content...
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
File: `/usr/bin/perl'
Size: 6912 Blocks: 16 IO Block: 4096 regular file
Device: 803h/2051d Inode: 15469221 Links: 2
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2011-11-06 01:40:14.000000000 +0100
Modify: 2011-11-06 01:40:14.000000000 +0100
Change: 2012-02-22 19:00:19.540964083 +0100
 
Second folder that I place test.sh is the cgi-bin folder where the scripts are that I was trying to cron.
A cron for /var/www/vhosts/mydomain.com/cgi-bin/test.sh didn't produce an outfile but sent an error email.
Again, if I open a terminal and use bash /path to test.sh, it then produces the test.out file with content...
I'd suspect there's a problem with your chroot environment. What's the complete error message in that email?
 
The email just contained this

-: /var/www/vhosts/mydomain.com/cgi-bin/test.sh: No such file or directory

Thanks very much for your continued help on this.
 
The email just contained this

-: /var/www/vhosts/mydomain.com/cgi-bin/test.sh: No such file or directory
Heh, I've reproduced yur problem. Looking in /var/spool/cron/mytestuser I could see that the cron is configured to run under a restricted shell, I have "SHELL=/usr/local/psa/bin/chrootsh" in that file. As soon as I commented this entry out the path to the executable file was found. Then I found this page:
http://download1.parallels.com/Ples...inistrator-guide/index.htm?fileName=66791.htm
Looks like this explains it. While we're here, I don't understand exactly why Parallels decided to allow the users to configure scheduled tasks with a restricted shell, that shell being unusable anyway? Why would you offer access to an unusable feature?
 
burnleyvic, you are a god!

Cron is working now. Thankyou so much for helping this novice.

Who would have guessed we had to unlock shell access for crontab from the command prompt even after we've given the accounts full shell access in the account setup.

Thanks again. Your time, patience, and advice has been gratefully received and very much appreciated. Hope that one day I can repay your kindness.

Kris
 
Works

This works for me.

I was pointed to http://kb.parallels.com/en/115842 to add new programs to a chrooted shell environment

and tried all there is to get the scheduled task to work but couldn't.

wget, php, lynx... none of them worked with error like :command not found or :error not found

REM-ed out SHELL... in /var/spool/cron/testuser and it worked straight away!

THANK YOU SO MUCH
 
Back
Top