Sorry, I referred to the log entries you provided Dec 6 10:45:01 CRON[23343]: (www-data) MAIL (mailed 74 bytes of output but got status 0x004b from MTA#012)
and thought it is the context of user www-data your web server is running with.
Maybe you can also provide the output of: ps -ef | grep -Ei "apache|nginx" | grep -v "grep"
@SyS0p3r I went to my nextcloud file located in my server here : /run/user/1000/gvfs/sftp:host=home6XXXXX.1and1-data.host/nextcloud
I did ls -alh and it gave me :
ls: impossible d’ouvrir le répertoire ‘.’: Permission non accordée
Which means in English : ls: impossible to open the directory "." : authorisation not granted
To continue to answer you :
I have no idea if my provider allows me to run cronjobs. How can I know ?
To run php I did :
** sudo -s
** ssh u8XXXXX@home6XXXXX.1and1-data.host
** cd ~/nextcloud
** php -f ./cron.php
and it gave me :
< br />
< b>Parse error< /b>: syntax error, unexpected ‘{’ in < b>/homepages/4X/d6XXXXXX/htdocs/nextcloud/cron.php< /b> on line < b>40< /b>< br />
@Schmu I tried to run ps -ef | grep -Ei "apache|nginx" | grep -v "grep" but when I press enter, nothing happens ?
Do you enter your server with sftp of directly ssh? I thnk you need to contact your hosting provider (1and1) and ask them if and how you can run cronjobs. It’s not a nextcloud issue, but it’s just not clear how you connect to the server and if you have cron permissions at all. Just tell them you need to create a cronjob for cron.php in the nextcloud folder and if they can advise you about how to do so.
I followed step by step the tutorial and it appears that despite all we’ve done together no crontab was created for the user provided by 1&1. When I did in SSH :
crontab -l
result : no crontab found (or something like it)
Then I tried what was said in the tutorial and did :
crontab -e
which opened a new crontab file, with Vim editor. I went to the last line, pressed the key “i” (for insert) and put : */15 * * * * /usr/bin/php /kunden/homepages/4X/d6XXXXXX/htdocs/nextcloud/cron.php
then ESC and wrote :x pressed enter to quit and save the file.
Then I checked if there was a crontab for the user :
(uiserver):u8XXXXX:~$ crontab -l #Edit this file to introduce tasks to be run by cron.
#Each task to run has to be defined through a single line #indicating with different fields when the task will be run #and what command to run for the task
#To define the time you can provide concrete values for #minute (m), hour (h), day of month (dom), month (mon), #and day of week (dow) or use ‘*’ in these fields (for ‘any’).# #Notice that tasks will be started based on the cron’s system #daemon’s notion of time and timezones.
#Output of the crontab jobs (including errors) is sent through #email to the user the crontab file belongs to (unless redirected).
#For example, you can run a backup of all your user accounts #at 5 a.m every week with: #0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#For more information see the manual pages of crontab(5) and cron(8)
#m h dom mon dow comman
*/15 * * * * /usr/bin/php /kunden/homepages/4X/d6XXXXXXX/htdocs/nextcloud/cron.php
I did a service ssh restart
It seems it’s working !
But… still red flag in the Nextcloud admin pannel…
As mentioned earlier, the cron job needs to be defined for the correct user. The documentation of nextcloud reads:
Cron
Using the operating system cron feature is the preferred method for executing regular tasks. This method enables the execution of scheduled jobs without the inherent limitations the Web server might have.
To run a cron job on a *nix system, every 15 minutes, under the default Web server user (often, www-data or wwwrun), you must set up the following cron job to call the cron.php script:
I thought about that too, but was under the impression that the default-user is the webserver-user. He doesn’t have full controll over the server, it’s just web hosting and I’m not really sure what the right user/permission is in that case. Running the cron.php from the commandline as the wrong user should normally result in a warning, telling you to run it as the webserver-user, and not some kind of parse-error.
But Tuhadj might as well check which user owns all the NC-files: “ls -la /kunden/homepages/4X/d6XXXXXX/htdocs/nextcloud”
Checking the php-modules, as suggested by SyS0p3r, is probably a good idea.
Well @SyS0p3r I did a check up of all php modules, I was missing a pdo_sqlite3 (for now I am using Sqlite, I’ll change to MariaDB but it is my next target after getting done with Cron). I installed pdo_sqlite3 and no change, red flag still in place for Cron.
Hm, this tutorial suggested that there might be one and that the default php-cli-version is 4.4. It might be outdated though.
I’m still convinced that this is a PHP-issue. PHP doesn’t understand what’s on line 40 of your cron.php. But I have no clue about PHP or the PHP-setup on your server.
I know the thread is old, but it didn’t seem to offer a working solution and reasons why offered suggestions might fail. One of my nextcloud instances runs on shared hosting. There is no www-data user and there are no files in /var/log for troubleshooting. I got the cron job running with:
0,15,30,45 * * * * cd /home/username/public_html/nextcloud; /usr/local/bin/php -f /home/username/public_html/nextcloud/cron.php
You should always cd to the path of the php script before running it in case the php script looks for files relative to the current folder. You also need to specify the php command with its full path because commands that run from cron do not load all the paths that are loaded from the ssh terminal shell because cron commands do not load /etc/bashrc or ~/.bashrc or ~/.bash_profile beforehand.
To find the path of your php command, type 'which php' into the ssh terminal window.
If you run a cron job for the command 'set > /tmp/vars.txt' and then from the terminal type 'cat /tmp/vars.txt | grep PATH' you will notice that the PATH variable only has /usr/bin and /bin. There is no /usr/local/bin etc so the php command is not found and cannot run. Setting the script to run on the hour, 15 past etc made more sense to me rather than every 15 minutes.