Results 1 to 16 of 16

Thread: Scheduled Tasks not Working

  1. #1
    Kilo Poster
    Join Date
    Nov 2011
    Posts
    33

    Default Scheduled Tasks not Working

    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



  2. #2

  3. #3
    Kilo Poster
    Join Date
    Nov 2011
    Posts
    33

    Default

    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.



  4. #4
    Mega Poster
    Join Date
    Nov 2011
    Posts
    152

    Default

    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?



  5. #5
    Kilo Poster
    Join Date
    Nov 2011
    Posts
    33

    Default

    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 by KrisScott; Feb 26, 2012 at 10:22 PM.



  6. #6
    Kilo Poster
    Join Date
    Nov 2011
    Posts
    33

    Default

    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.



  7. #7
    Mega Poster
    Join Date
    Nov 2011
    Posts
    152

    Default

    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.



  8. #8
    Kilo Poster
    Join Date
    Nov 2011
    Posts
    33

    Default

    Thanks again burnleyvic.

    I did what you suggested. The email response is the same.

    -: /usr/bin/perl: No such file or directory



  9. #9
    Mega Poster
    Join Date
    Nov 2011
    Posts
    152

    Default

    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?



  10. #10
    Kilo Poster
    Join Date
    Nov 2011
    Posts
    33

    Default

    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



  11. #11
    Mega Poster
    Join Date
    Nov 2011
    Posts
    152

    Default

    Quote Originally Posted by KrisScott View Post
    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?



  12. #12
    Kilo Poster
    Join Date
    Nov 2011
    Posts
    33

    Default

    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.



  13. #13
    Mega Poster
    Join Date
    Nov 2011
    Posts
    152

    Default

    Quote Originally Posted by KrisScott View Post
    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/Plesk...Name=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?



  14. #14
    Kilo Poster
    Join Date
    Nov 2011
    Posts
    33

    Default

    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



  15. #15
    Kilo Poster
    Join Date
    Oct 2011
    Posts
    19

    Default

    Thank you! Thank you! Thank you! Thank you! Thank you!



  16. #16
    Bit Poster
    Join Date
    May 2014
    Posts
    2

    Thumbs up 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



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •