crontab bash tests
lejeczek
peljasz at yahoo.co.uk
Tue Sep 26 06:33:05 UTC 2023
On 24/09/2023 18:44, lejeczek via ubuntu-users wrote:
> Hi guys.
>
> I have this
>
> */1 * * * * { [[ $(/usr/bin/sudo -u postgres /usr/bin/psql
> --quiet --port=5433 -x -c 'select state from
> pg_stat_replication;' | grep streaming > /dev/null)$? -eq
> 0 ]] && /usr/bin/touch /tmp/pgSQL-5433.isMaster || rm -f
> /tmp/pgSQL-5433.isMaster; }
>
> which in regular shell session touches the file, but in
> the cron file gets removed, the opposite & actually the
> only outcome, regardless of whether the test is true or false.
> What is going on there?
> many thanks, L.
>
I appreciate all the feedback, I do, however -- on purpose
or not --- everybody seems to have ignored my second,
equally important point.
Whether
if ..
[ ..
[[ ..
and I tried them all, outside of _cron_ the same command
line, copy&paste, works as expected, tests works as expected.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20230926/65cdb51a/attachment.html>
More information about the ubuntu-users
mailing list