Re: error messages not getting logged when running script from cron

Поиск
Список
Период
Сортировка
От anj patnaik
Тема Re: error messages not getting logged when running script from cron
Дата
Msg-id CAEQKwSkw7BR0+X9BjS07aBbfp0Tx8FwjcpAJxFvF6dFm-XJceg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: error messages not getting logged when running script from cron  (Melvin Davidson <melvin6925@gmail.com>)
Ответы Re: error messages not getting logged when running script from cron  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
I am seeing a bizarre behavior. The command works fine when called directly from prompt, but when invoked via cron, there is no output nor mail.

This works fine:
script 2>&1 | tee /tmp/ff ; mailx -s "email" -myemail@company.com < /tmp/ff

Now, I place the identical line in crontab file and the output file /tmp/ff does not get generated.

Inside script, i am running a pg_restore which dumps output to stdout. The usage of tee is the only way to cause it to go into a file.

Any idea here? Thanks

On Mon, Nov 23, 2015 at 3:29 PM, Melvin Davidson <melvin6925@gmail.com> wrote:
You could also try tweaking the following attached backup script.
Caution, I wrote this quickly from a skeleton script and has not been tested.

On Mon, Nov 23, 2015 at 3:21 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
anj patnaik <patna73@gmail.com> writes:
> My cron tab entry:

> 0 20 * * * db_backup.sh 1> /dev/null 2>&1 | mail -s "backup cron"
> myemail@comp.com

> I am re-directing stderr to stdout and then sending that to email.

Uh, read it again: you're redirecting stdout to /dev/null and then
redirecting stderr to go where stdout goes.  So all output is
going to the bit bucket, not the pipe.

                        regards, tom lane


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.


В списке pgsql-general по дате отправления:

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: "trust" authentication in pg_hba.conf
Следующее
От: Caleb Meredith
Дата:
Сообщение: Can row level security policies also be implemented for views?