shellcheck icon indicating copy to clipboard operation
shellcheck copied to clipboard

Support crontab checking

Open mkesper opened this issue 2 months ago • 0 comments

For new checks and feature suggestions

  • [X] https://www.shellcheck.net/ (i.e. the latest commit) currently gives no useful warnings about this
  • [X] I searched through https://github.com/koalaman/shellcheck/issues and didn't find anything related

My apologies if this was already discussed but my searches did not turn up anything relevant here.

Here's a snippet or screenshot that shows a potential problem:

#shellcheck shell=crontab
PATH=/sbin:/bin:/usr/sbin:/usr/bin
# Run all jobs with up to 15 min delay to avoid resource spikes
RANDOM_DELAY=900
*/10 * * * * bash -lc "sleep \$((RANDOM % RANDOM_DELAY)); echo Still alive!

Here's what shellcheck currently says:

[Line 5:](javascript:setPosition(5, 1))
*/10 * * * * bash -lc "sleep \$((RANDOM % RANDOM_DELAY)); echo Still alive!
^-- [SC1009](https://www.shellcheck.net/wiki/SC1009) (info): The mentioned syntax error was in this simple command.
                      ^-- [SC1073](https://www.shellcheck.net/wiki/SC1073) (error): Couldn't parse this double quoted string. Fix to allow more checks.
>>

Here's what I wanted to see:

An analysis of the shell code to be executed via cron. For that to work, I suggest a remark with shell=crontab (or similar) and parsing according to POSIX cron definitions.

Thanks for your awesome tool and any input re this request!

mkesper avatar Nov 04 '25 09:11 mkesper