Question

Issues with CRON job executing on Ubuntu 20.04 with PHP 7.4 FPM

I am having issues properly setting up the following CRON job to automate backups on my client’s website.

The site is Joomla-based and I am using Akeeba Backup to handle the backups. The recommendations for the command-line CRON jobs are as follows:

Use the following command in your host’s CRON interface: /path/to/php /var/www/domain.com/cli/akeeba-backup.php

Remember to substitute /path/to/php with the real path to your host’s PHP CLI (Command Line Interface) executable. Do remember that you must use the PHP CLI executable; the PHP CGI (Common Gateway Interface) executable will not work with our CRON scripts. If unsure what this means, please consult your host. They are the only people who can provide this information.

domain.com used as an example

I have CRON installed and running on Ubuntu 20.04.

The following code is in crontab -e

0 3 * * * /usr/bin/php7.4 /var/www/domain.com/cli/akeeba-backup.php --profile=1 --description="Full automated backup"

The site is running PHP 7.4 with FPM installed.

When I run which php the following is returned: /usr/bin/php

When I run ls -l /usr/bin/php the following is returned: lrwxrwxrwx 1 root root 21 Aug 31 18:09 /usr/bin/php -> /etc/alternatives/php

When I run ls -l /etc/alternatives/php the following is returned: lrwxrwxrwx 1 root root 15 Aug 31 18:53 /etc/alternatives/php -> /usr/bin/php8.0

As this shows version 8.0 instead of 7.4, which the site is using, does this mean the CRON job should be using version 8 instead.

Sample log output from /var/log/syslog

Oct 1 11:39:01 domain CRON[38538]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)

Any help is greatly appreciated.

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Hello,

As the website uses PHP 7.4, I believe that it is best to run the cronjob with PHP 7.4 as well for consistency.

To check if this /usr/bin/php7.4 is the correct path to the PHP 7.4 executable, you could run the following command:

/usr/bin/php7.4 -v

If the output indicates that the PHP version is 7.4, then I could suggest running the command manually:

/usr/bin/php7.4 /var/www/domain.com/cli/akeeba-backup.php --profile=1 --description="Full automated backup"

That way you will be able to see if there are any errors when the command is executed.

If you get any errors feel free to share them here after removing any sensitive information from the output.

Regards, Bobby