Skip to content

Managing cron

scubamuc edited this page Jul 20, 2024 · 14 revisions

Managing Nextcloud snap cron

View cron configuration with "get"

sudo snap get nextcloud nextcloud.cron-interval

Set cron configuration with "set"

value =10 in minutes

sudo snap set nextcloud nextcloud.cron-interval=10

Restart cron manually

sudo snap restart nextcloud.nextcloud-cron

If cron fails after update

sudo nextcloud.occ background:cron

Disable cron

sudo snap set nextcloud nextcloud.cron-interval=-1

Enable cron

value =10 in minutes

sudo snap set nextcloud nextcloud.cron-interval=10

Managing cron on the host

The complete cron job guide

View root crontab on host

sudo crontab -l

Edit root crontab on host

sudo crontab -e

Add root cronjob as root

* * * * * nextcloud.occ <function>:<command> <--option>

Examples:

  • scan files * * * * * nextcloud.occ files:scan --all

  • preview generator * * * * * nextcloud.occ preview:generate-all -vvv

  • clean trash * * * * * nextcloud.occ trashbin:cleanup --all-users

Add root cronjob as user

best practice to run user scripts requiring root privileges as cronjob

* * * * * su <USER> /home/<USER>/path/to/script.sh

Required schedule expression

see https://crontab.guru/

Clone this wiki locally