Rev. LeRoy D. Cressy via plug on 23 Aug 2019 08:08:32 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Shell syntax vs crontab syntax


Hi Walt,

crontab accesses /bin/sh which is usually a symlink to a shell and not always bash.  Bash behaves differently when invoked from /bin/sh.

Stackoverflow has a good article on this.

https://stackoverflow.com/questions/26717870/why-does-bin-sh-behave-differently-to-bin-bash-even-if-one-points-to-the-other


Rev. LeRoy D. Cressy

I hope you enjoy my posts on the following sites:

Blogs:

Minds https://www.minds.com/lrcressy
Flote https://flote.app/therev
FaceBook https://www.facebook.com/leroy.cressy
Gab https://gab.com/the-rev
Twitter https://twitter.com/lrcressy

Videos:

YouTube https://www.youtube.com/channel/UCqrVrZbgneD5EiSCjj1WSuQ
Bitchute https://www.bitchute.com/channel/s0Lo9GISDVue/
Real Video https://www.real.video/channel/therev

Some of these sites may remove me for my views, which
is their right.  I publish what I believe to be
true and accurate.

John 14:6
Jesus saith unto him, I am the way, the truth, and the
life: no man cometh unto the Father, but by me.

Sent with ProtonMail Secure Email.

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, August 23, 2019 10:07 AM, Walt Mankowski via plug <plug@lists.phillylinux.org> wrote:

> I run fail2ban and it generates a lot of email. I decided to switch
> from putting everything in one enormous maildir to monthly maildirs.
> Rather than making a whole bunch (and then likely forgetting about it)
> I figured I'd make a cron job that would add the next month's folder.
>
> If I run this on the command line it works fine:
>
> maildirmake /tmp/fail2ban.`date --date='next month' '+%Y%m'`
>
> But when I tried to use that same syntax in my crontab I got the message:
>
> /bin/sh: 1: Syntax error: EOF in backquote substitution
>
> What ended up working was this:
>
> maildirmake /tmp/fail2ban.`date --date='next month' \\+\\%Y\\%m`
>
> I've run into situations like this in the past where the quoting rules
> for the shell and crontab seem to be different. I've never found
> anything that explains why it's different. Is it because I'm using
> zsh?
>
> Walt
>
> Philadelphia Linux Users Group -- http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug


___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug