Crontab not working with script?

Nextcloud version (eg, 18.0.2): 19.0.0
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.41 (Ubuntu)
PHP version (eg, 7.1): PHP 7.4.9

The issue you are facing:
Cronjob not working…

Is this the first time you’ve seen this error? (Y/N):
Yes

Steps to replicate it:
Okey…

I am trying to install Nextcloud with a script atm and I am getting that the Cronjob haven’t run in over 50 years right after the installation is completed (No… I didn’t wait 50 years. :stuck_out_tongue: )

The code that I use:

echo "Creating crojobs for Nextcloud"
sudo echo "*/5  *  *  *  * php -f /var/www/html/nextcloud/cron.php" >> /var/spool/cron/crontabs/www-data
sudo -u www-data php /var/www/html/nextcloud/occ background:cron

The weird part is that If i go to CLI and do to the crontab

sudo crontab -u www-data -e

and just saves again without editing anything, it will start to work again.

image
Any idea’s how I can fix this so I don’t need to do that step? So that it is 100% automated?

Thanks in advance!
/Rojz

EDIT:
After the installation on the Nextcloud I did even wait 5+ min jus to see if the cron would kick in, but it didn’t. only kicks in after i save the file again.

Have a look at this:

It seels like that worked! Thanks you so much!

1 Like

No problem! :slight_smile: