Мне это понадобилось для автоматического подъема сервиса после внештатной перезагруз...
Мне это понадобилось для автоматического подъема сервиса после внештатной перезагрузки сервера.
Как всегда, все просто:
su USER -c '/home/USER/folder/script.sh'
Собственно man su рассказывает всё в примерах.
su man -c catman
# Runs the command catman as user man. You will be asked for man's password unless your real UID is 0.
su man -c 'catman /usr/share/man /usr/local/man'
# Same as above, but the target command consists of more than a single word and hence is quoted for use
# with the -c option being passed to the shell. (Most shells expect the argument to -c to be a single word).
su -l foo
# Simulate a login for user foo.
su - foo
# Same as above.