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?

  • Try to run '$ su [username][command]' Jul 31, 2014 at 20:22

1 Answer 1


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.

  • Thanks, I wasn't able to get it working with those. But I do now see that I can create a crontab for anyone. The commands wound up running fine as root with sudo. I didn't know I could use sudo there (was expecting it to fail waiting for a password). Jul 31, 2014 at 22:22
  • 2
    @Louis sudo does not require a password when you invoke it as root. Basically you're not gaining permissions but giving them up.
    – kraxor
    Aug 1, 2014 at 10:58
  • 1
    @kraxor - you could just run crontab -e when logged in as that user. i think this is not correct .
    – bhv
    Oct 20, 2016 at 4:07
  • Could the specific user has root permissions during the run?
    – alper
    Nov 19, 2020 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .