Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5216

Advanced users • Re: Cronjob help! (please)

$
0
0
2) Among other failings, cron runs jobs with /bin/sh (which is a primitive, limited shell) rather than the /bin/bash that you are used to.
Why not set the shell to bash with

Code:

SHELL=/bin/bash
in your crontab entry.
I generally advise against changing system defaults like that, when there's an easy alternative. It's probably not all that likely to cause a problem, but it makes a subtle change to a system-level environment which could break something else (possibly in the future, long after you've forgotten you changed it). I.e. are you certain that bash will perfectly replicate the behaviour of dash for all use cases? It's generally much safer and more maintainable to put your bash script into an executable file, then execute that file. It probably would work fine changing the shell in crontab, probably is reasonably unlikely to cause a problem, but why take the chance with it? Even if it works now, some future update may land on something where dash and bash have divergent behaviour.

Statistics: Posted by Murph9000 — Mon Jan 06, 2025 9:10 pm



Viewing all articles
Browse latest Browse all 5216

Trending Articles