How to add a spesific occ command to crontab

Hi,
I use owncloud 10.0.10 on Ubuntu 16.04
I have to run user:sync command every 10 min.:

sudo -u www-data php occ user:sync "OCA\User_LDAP\User_Proxy" -m disable -r

So:

crontab -u www-data -e
*/10 * * * * /usr/bin/php /var/owncloud/occ user:sync "OCA\User_LDAP\User_Proxy" -m disable -r

is enough to do it? Or, should I have to use different method? I read crontab document but it is not clear for me.

Yes this will add the cronjob into the crontab of the user www-data. The cronjob will then be executed as that user.
Make sure to add trailing new line in the file as the crontab is invalid otherwise and the cronjob won’t execute.
I usually check the execution of a cronjob that has been set to execute every minute in the systemlog before adjusting it to the correct time.

Depending on how large your user directory is, 10 minutes might be too often. However for most user directories the sync only takes a couple of seconds and the sync should be OK. Anyhow we usually recommend to just run it several times a day, e.g 0 */4-6 * * *. To get cron times to plain English I use https://crontab.guru/

2 Likes