cronjobThe ownCloud VM contains a built in script that handles the updates automatically, set to execute at any given time by the user. In other words, you can decide by yourself how often you want to backup your server. The secret behind it is a piece of software called cron, which is a Linux scheduler. If you’re used to Windows you might refer to it as the Task Scheduler. Cron makes it possible to schedule any task you want, and works great in combination with backup scripts. We previously wrote about how to set up cron with QNAP, which was a bit tricky, but in a standard Ubuntu distro it’s very easy. We prepared everything for you so the only thing you have to do is to activate it.

How it works

Once you activated the cronjob and the script is executed it will begin with removing unused packages as it just takes unnecessary space. When that is done it will update the whole system, and also upgrade ownCloud to the latest version through the occ command that ownCloud has built in since server version 7.0. We’ve also activated some standard apps, and if you want some other apps to be activated, you just change the script to enable the apps you prefer instead.  When the upgrade is successfully executed it will set secure permissions and write the output into a log so that you can check that everything works as it should.  So basically you won’t have to do anything, just let the script + cron do the magic, and you will always have a secure and updated system. Pretty neat.

How to set it up

  1. first, make sure you’re root
    $~: sudo -i

    Password: owncloud

  2. edit the crontab
    $~: crontab -e
  3. add the command as a cronjob
    10 0 * * 6 /var/scripts/owncloud_update.sh
    |  | | | |
    |  | | | |__ weekday (0-6, 0 = Sunday)
    |  | | | ___ month (1-12)
    |  | |______ day (1-31) 
    |  |________ hour (0-23, 0 = midnight)
    | __________ minute (0-59)

    This command will execute every Saturday at midnight (00:10)

  4.  Save and Exit
    [CTRL + X] + [Y] (yes) + [ENTER]
  5.  Make it executable

    To allow the script to be executed by cron, you have to make it executable. To do this just use chmod to set the correct permissions.

    $~: chmod +x /var/scripts/owncloud_update.sh
  6. Test that it works

    It would take one week for the above command to run, and you don’t want to wait that long, right? To test that it works, change the script to be executed five minutes after you saved it instead.

    5 * * * * /var/scripts/owncloud_update.sh

    If everything works, the script should have written the output to the log. To check if it was successful, just check the log

    $~: nano /var/log/cronjobs_success.log

    And look for this:

    OWNCLOUD UPDATE success-20150709
  7. Wohaa, you made it.


 Pro tip

Make daily backups of your server, here is a guide.

Install ownCloud and host your own private cloud. Download the pre-configured ownCloud VM today!