Kyle Hamilton
asked on
execute scripts using different users through cron
Hi,
I'm trying to execute several scripts through cron.
Some scripts require being run as different users.
so through cli, I can do:
but inside a script that is triggered with cron, this doesn't work.
So I tried it like this:
without success.
Any ideas?
I'm trying to execute several scripts through cron.
Some scripts require being run as different users.
so through cli, I can do:
sudo -u username . /path/to/script.sh
but inside a script that is triggered with cron, this doesn't work.
So I tried it like this:
su --shell=/bin/bash --session-command="/path/to/script.sh" username &
without success.
Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Alternatively, make /path/to/script.sh executable.
Also, you don't need the & at the end - cron runs jobs separately from each other, and expects them to run in the foreground.
Otherwise fine!!
Also, you don't need the & at the end - cron runs jobs separately from each other, and expects them to run in the foreground.
Otherwise fine!!
ASKER