I try to run cron.php within cronjob but it seems like I’m missing something.
I’ve a dedicated server with plesk so the cronjob has not to be for user www-data as suggested in the manual.
Nextcloud is telling under which user the cronjob should be run so I’m taking this instead.
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
*/15 * * * * php -f /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php #DOES NOT WORK
*/15 * * * * /usr/bin/php -f /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php #DOES NOT WORK
*/15 * * * * /bin/bash -c “php /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php” #DOES NOT WORK
*/15 * * * * bigdeal /bin/su -s /bin/sh -c “/usr/bin/php -f /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php” #DOES NOT WORK
With sudo grep CRON /var/log/syslog
I get this output
Dec 20 23:54:01 server CRON[17092]: (bigdeal) CMD (php -f /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php)
Dec 20 23:55:01 server CRON[17157]: (bigdeal) CMD (/bin/sh -c “php -f /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php”)
Dec 20 23:55:01 server CRON[17159]: (bigdeal) CMD (/usr/bin/php -f /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php)
Dec 20 23:55:01 server CRON[17160]: (bigdeal) CMD (bigdeal /bin/su -s /bin/sh -c “/usr/bin/php -f /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php”)
This tells me, that those commands have been executed.
I read about problems with pathes, but since I use absolute pathes that should not be the case.
So:
What am I missing here?
What user are you running you test cron jobs as? By default, sudo only allows root to run commands as another user (“bigdeal”). Put your cron jobs that require sudoing to another user into root’s crontab and see what happens.
I you need to have the cron job run as the same user that runs the webserver. I don’t know what Linux flavor plesk uses, but under redhat the user “apache” needs the crontab.
Check to see who owns the nextcloud directory, that’s probably the user that needs the crontab entry.
the owner of the nextcloud directory is “bigdeal”. In the admin panel is also mentioned that the cronjob has to be run under this user. So I’m pretty sure that this should be the right user.
I think by doing crontab -u bigdeal -e and sudo crontab -e you’ve pretty much done the same thing (presuming you’re logged in as ‘bigdeal’). Try logging in as root and doing crontab -e or doing sudo crontab -u root -e.
crontab -u root -e returns must be privileged to use -u
and sudo crontab -u root -l
just like sudo crontab -l or logged in as root crontab -l
all give me this
Dec 22 13:55:01 essen127 CRON[18300]: (root) CMD (/usr/bin/php -f /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php
was an additional output of sudo grep CRON /var/log/syslog
and after editing with crontab -e this line was added
Dec 22 13:55:01 essen127 CRON[18299]: (bigdeal) CMD (/usr/bin/php -f /var/www/vhosts/bigdeal/nextcloud.big.deal/cron.php)
All commands have been executed beeing logged in as user ‘bigdeal’.
So to me it seems like crontab -u bigdeal -e and sudo crontab -e are not the same thing.
I did it allover again and I found my mistake. I did it by copy & paste but somehow I managed to make a typo anyway.
I’m very sorry for wasting your time!