crontab bash tests
lejeczek
peljasz at yahoo.co.uk
Tue Sep 26 06:40:54 UTC 2023
On 26/09/2023 08:33, lejeczek via ubuntu-users wrote:
>
>
> 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.
>
>
ough, okey, seems that I was missing:
SHELL=/usr/bin/bash
if I was to expect Ubuntu's _crond_ to behave more like
defaults in RHEL/Centos.
many thanks, L
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20230926/840e0eb1/attachment-0001.html>
More information about the ubuntu-users
mailing list