Skip to content

Exit non-zero when running crontab -l -u user_that_doesnt_have_a_crontab #31

Open

Description

@h3xx

I'd like to understand why this implementation of crontab is designed to exit zero when asking to list a crontab for a user that doesn't have a spool file. To me, it makes sense to exit non-zero in this instance. It would be great if crontab did this.

Not saying this project needs to follow suit, but cronie exits nonzero under the same conditions. Cronie is the default in CentOS and RHEL.

My particular use case is that I'm writing a shell script that backs up a user's current crontab to a file and deletes it:

if crontab -l -u www-data >/tmp/www-data.crontab.bak; then
    mv -i /tmp/www-data.crontab.bak .
    crontab -d -u www-data
fi

(I know could of course pipe the output to wc -l.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions