• 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

User account can't run cron?

J

JDub@

Guest
Hi,

I'm having some trouble running a cron script as a user within Plesk 7.5.4. The target file is being found fine, but I'm unable to access PHP in order to run it.

Upon running the following command: -

/usr/local/psa/admin/bin/php /var/www/vhosts/domain/httpdocs/tasks_minute.php5

I get the following error in the email sent to me: -

/bin/sh: /usr/local/psa/admin/bin/php: Permission denied

Server cron runs fine, but then they run as root!

Why is this? Am I pointing to the wrong PHP, or should I run this as a server cron? I don't really want to, as it only applies to a specific domain.

Any help on this would be MUCH appreciated!!

Regards

Jules.
 
Wrong PHP. It's a pretty safe assumption that anything user related will not be under /usr/local/psa/admin

Try 'which php' to find the "real" version of PHP. Also, you will probably need the -f flag in your command.
 
Many thanks for the feedback - Quick Q's: -

Where do I search for 'which php'?
Also what syntax is the -f flag entered - i.e. where in the command string?

Regards

Jules.
 
just type the following in a shell (SSH):
which php

The -f flag is a php flag, so it would go after php, and before the file name. For example:

php -f /var/www/vhosts/domain/httpdocs/tasks_minute.php5
 
Many thanks for your help there - I haven't solved the problem yet, but I'm a few steps closer!! :)

Out of curiosity, what does the -f flag do?

Regards

Jules.
 
root@ns ~>php -h
Usage: php [-q] [-h] [-s] [-v] [-i] [-f <file>]
php <file> [args...]
-a Run interactively
-C Do not chdir to the script's directory
-c <path>|<file> Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value 'bar'
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q'
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
 
Hello,

Try on the crom command:

/usr/bin/php /home/httpd/vhosts/domain/httpdocs/path/file.php >/dev/null

and check that your php file starts with:

#!/usr/local/bin/php -q

Hope this helps.

Cheers,

DXTrim
 
Many thanks for the input folks. My developer managed to suss it out with the input of the poster above - It took a little more shuffling around, but this was the final command that appears to the job: -

(pushd '/var/www/vhosts/domain/httpdocs'; /usr/bin/php -e -f tasks_minute.php5; popd)

Cheers

J>
 
Back
Top