See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

How to redirect program error to a file while using pipes

General Tech Bugs & Fixes
Max. 2000 characters

Vanshika Bhatt


( 8 months ago )

I'm running a command to backup my DB:

(echo "`date`: START DUMPING";; echo "`date`: DONE DUMPING") >>db_dump.log

And in the

pg_dump -v --dbname=mydb | pigz | openssl enc -aes128 -k ssecret -out db_dump.gz.aes

How would I catch the informative output from pg_dump, pigz and openssl to db_dump.log?

Currently I'm thinking doing it:

pg_dump -v --dbname=mydb 2>>db_dump.log| pigz 2>>db_dump.log| openssl enc -aes128 -k ssecret -out db_dump.gz.aes 2>>db_dump.log

but that seems quite cumbersome...

Pooja Bhardwaj


( 8 months ago )

Try grouping with brackets:

( pg_dump -v --dbname=mydb | pigz | openssl enc -aes128 -k ssecret -out db_dump.gz.aes ) 2>>db_dump.log

Individual stderr output from all parts of the pipe will go into the same destination.

what's your interest