How to run a cron job as a specific user?
I have a couple of commands I want executed after the machine boots up. A user shouldn't have to log in or anything for them to run.
I found this great answer suggesting crontab with the @reboot
keyword, however this will run as root, and I'd like to run as a specific user created for these "services" (not actual system services).
What are someways to achieve that same effect with any given user?
You could create a crontab for the specific user like so:
crontab -u <username> -e
Or more simply, you could just run crontab -e
when logged in as that user.
Alternatively, you could prefix your command in your (root) crontab with sudo -u <username>
to run the command as the specified user.