Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Why won't my crontab work?

This is an ongoing problem on Ubuntu. My BIOS is configured to start my computer after midnight to avail of unlimited downloads, the crontab is supposed to kick in with root access and download and install the updates but it doesn't seem to run.

I created the following crontab with the sudo prefix to get root access, see if you can see what might have gone wrong.

10 0 * * * /usr/lib/bin/apt-get update

20 0 * * * /usr/lib/bin/apt-get upgrade

51 0 * * * /usr/sbin/shutdown -P --quiet now

2 Answers

Relevance
  • 8 years ago
    Favorite Answer

    If you want to run commands automatically as root, put them directly in /etc/crontab

    The format of that is similar to the 'user' crontabs, but you also need the name of the user to run the commands - ie. root - as an extra parameter on each line.

    10 0 * * * root /usr/lib/bin/apt-get update

    20 0 * * * root /usr/lib/bin/apt-get upgrade

    51 0 * * * root /usr/sbin/shutdown -P --quiet now

    Append them after the existing stuff in the file.

  • 8 years ago

    Id you created these as system crontabs (under /etc) then you need a sixth parameter for the username to run the script as.

    For example:

    10 0 * * * root /usr/lib/bin/apt-get update

    If this is already root's own crontab then you don't need this.

    Cron emails errors to the user, so you might want to check root's emails to see what cron thought happened (or didn't happen):

    sudo mail -u root

Still have questions? Get your answers by asking now.