Add cronjob with bash script - No crontab for root

147

Sounds like (a) root's crontab is initially empty and (b) the -e option is set in the shell.

If the user's crontab file is empty then crontab -l exits with status 1.

If shell is running with -e option then it will exit immediately on failure (defined as exiting with non-zero status).

Look for errexit in the output of echo $SHELLOPTS to check for this setting. Turn it off in the current shell with set +e.

Share:
147

Related videos on Youtube

Lane Jessen
Author by

Lane Jessen

Updated on September 18, 2022

Comments

  • Lane Jessen
    Lane Jessen over 1 year

    I have a similar issue. However, I am trying to countif in reference to another cell:

    =Countif(Importrange("Sheet name", "'Sheet Tab"!DE:FH), "="&A3)
    

    but get 0 for the result.

    • ott--
      ott-- about 9 years
      Check if you have root in /etc/cron.deny.
    • Jimmy
      Jimmy about 9 years
      @ott-- I don't have that file at all, just cron.d cron.daily cron.hourly cron.monthly crontab cron.weekly
    • mdpc
      mdpc about 9 years
      Hate to ask a dumb question, but are you root when you execute these commands? Also instead of the raw commands please provide the transcript of their run.
    • Jimmy
      Jimmy about 9 years
      @mdpc I am root yes. I will upload the full script when I get to my laptop but it's just that command with a #!/bin/bash header
    • Jimmy
      Jimmy about 9 years
      @JennyD my reply in the answer below solved it which doesn't appear on you link
    • HBruijn
      HBruijn about 9 years
      Typically when scripting and packaging (and running as root) dropping a new file with a cron entry in /etc/cron.d is easier to maintain.
  • Dr.jacky
    Dr.jacky about 7 years
    echo $SHELLOPTS -> braceexpand:emacs:hashall:histexpand:history:interactive-com‌​ments:monitor
  • Cédric Françoys
    Cédric Françoys over 5 years
    Just in case : Ubuntu stores root contab under /var/spool/cron/crontabs/root