Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 6015

Switch user before running cmd ubuntu [duplicate]

$
0
0

I'm trying to run a cron job in ubuntu server to backup my database every day.

so Im using this cmd:

sudo -i -u postgres && pg_dump -Fc DbName > DbName_backup.dump && ... && ... && ...

the problem I have is that you can not switch user and run command in a single statement, it never works.

I have to call sudo -i -u postgres then in another statement call pg_dump -Fc DbName > DbName_backup.dump && ... && ... && ...

But I want it to work in a single statement.


Viewing all articles
Browse latest Browse all 6015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>