且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我可以在bash脚本中间运行'su'吗?

更新时间:2023-12-05 14:30:28

可以,但是bash不会将后续命令作为postgres运行.而是:

You can, but bash won't run the subsequent commands as postgres. Instead, do:

su postgres -c 'dropdb $user'

-c 标志以用户身份运行命令(请参见 man su ).

The -c flag runs a command as the user (see man su).