开发者

sudoers syntax to run shell script as php user?

开发者 https://www.devze.com 2023-02-20 08:47 出处:网络
I want to run a shell script restore as postgres user from php script (the user name is php) using sudo 开发者_Python百科

I want to run

  • a shell script restore
  • as postgres user
  • from php script (the user name is php)
  • using sudo
  • 开发者_Python百科

the script will have few lines of code, something like

dropdb <database name>
psql -c "create database <database name> with encoding 'unicode';" -U edutemplate1
psql -d <database name> -f edu.hourly.sql 
  • what would be the sudo command syntax to run the script restore
  • what would be the sudoers syntax to allow php user to run restore script as postgres user?


The command is absolutely the same as you do in console:

sudo -u db1inst1 /path/to/script.sh

Or even:

system('sudo -u db1inst1 /path/to/script.sh');

or

`sudo -u db1inst1 /path/to/script.sh`
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号