su指定用户执行命令

命令行模式下

1
2
/etc/passwd中nologin改为bash
su user -s /bin/bash -c 'touch test.x'

/etc/crontab下

1
* * * * * user echo '12312' >> /tmp/test.x