Skip to content
README.rst 2.74 KiB
Newer Older
Kevin Lyda's avatar
Kevin Lyda committed
==========
chkcrontab
==========
Kevin Lyda's avatar
Kevin Lyda committed
.. image:: https://travis-ci.org/lyda/chkcrontab.png?branch=master
Kevin Lyda's avatar
Kevin Lyda committed
   :target: https://travis-ci.org/lyda/chkcrontab
Kevin Lyda's avatar
Kevin Lyda committed
   :alt: Build status

Crontab linter
==============
chkcrontab is a script to check crontab files like those in
``/etc/cron.d`` and ``/etc/crontab``.  It tries to catch glaring
errors and warn on suspect lines in a crontab file.  Some valid
lines will generate warnings.  Certain silly yet valid crontab lines
will generate errors as well.

Run this by doing::

    chkcrontab crontab_file

Errors will cause a non-zero exit code.  Warnings alone will not.

To see sample output for a bad crontab, run the following::

  ./chkcrontab ./tests/test_crontab

See the ``./tests/test_crontab.disable`` crontab for how to disable
warnings and errors.

Kevin Lyda's avatar
Kevin Lyda committed
Output Description
~~~~~~~~~~~~~~~~~~

The output of ``chkcrontab`` is described on the `CheckCrontab`_
wiki page. A link to it appears in the output if there were any
warnings or errors. It also suggests ways to fix the reported
issues.

Kevin Lyda's avatar
Kevin Lyda committed
Contributions
=============
Kevin Lyda's avatar
Kevin Lyda committed
Contributions are welcome! Please add unit tests for new features
or bug fixes.  To run all the unit tests run ``./setup test``.
Kevin Lyda's avatar
Kevin Lyda committed
If you have `tox`_ installed, just run ``tox``.
Kevin Lyda's avatar
Kevin Lyda committed

Kevin Lyda's avatar
Kevin Lyda committed
You can review `coverage`_ of added tests by running
``coverage run setup.py test`` and then running
``coverage report -m``.

Kevin Lyda's avatar
Kevin Lyda committed
Note that tests are run on `Travis`_ for all supported python
versions whenever the tree on github is pushed to.
Kevin Lyda's avatar
Kevin Lyda committed

Kevin Lyda's avatar
Kevin Lyda committed
The packaged version is available via ``pip`` or ``easy_install``
as ``chkcrontab``. The project page is on `pypi`_:

The source code is available in the following locations:
Kevin Lyda's avatar
Kevin Lyda committed

* Bitbucket: https://bitbucket.org/lyda/chkcrontab/
Kevin Lyda's avatar
Kevin Lyda committed
* code.google: https://code.google.com/p/chkcrontab/
Kevin Lyda's avatar
Kevin Lyda committed
* Github: https://github.com/lyda/chkcrontab
* Gitorious: https://gitorious.org/uu/chkcrontab
Kevin Lyda's avatar
Kevin Lyda committed
* Sourceforge: https://sourceforge.net/p/chkcrontab
Kevin Lyda's avatar
Kevin Lyda committed

Pull requests on any of those platforms or emailed patches are fine.
Opening issues on github is easiest, but I'll check any of them.
Kevin Lyda's avatar
Kevin Lyda committed

Kevin Lyda's avatar
Kevin Lyda committed
TODO
====
Kevin Lyda's avatar
Kevin Lyda committed
* Look for duplicate entries. Puppet sometimes loads up crontabs
  with dups.
* Check for backticks. (why?)
* Make sure MAILTO and PATH are set (perhaps others?).
* Add tests for command line.
Kevin Lyda's avatar
Kevin Lyda committed
* Enable it to parse user crontabs: https://code.google.com/p/chkcrontab/issues/detail?id=2
* Make "acceptable filenames" a configurable thing: https://github.com/lyda/chkcrontab/issues/4
Kevin Lyda's avatar
Kevin Lyda committed

Kevin Lyda's avatar
Kevin Lyda committed
Credits
=======
- `Kevin Lyda`_: Who got burned one too many times by broken crontabs.

Kevin Lyda's avatar
Kevin Lyda committed
.. _`tox`: https://pypi.python.org/pypi/tox
.. _`coverage`: https://pypi.python.org/pypi/coverage
.. _`Travis`: https://travis-ci.org/lyda/chkcrontab
Kevin Lyda's avatar
Kevin Lyda committed
.. _`Kevin Lyda`: https://github.com/lyda
.. _`CheckCrontab`: http://goo.gl/7XS9q
Kevin Lyda's avatar
Kevin Lyda committed
.. _`pypi`: https://pypi.python.org/pypi/chkcrontab