Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
h3xx opened this issue Feb 15, 2021 · 0 comments
Open

Comments

@h3xx
Copy link

h3xx commented Feb 15, 2021

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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant