# How to run a cronjob as a specific user?

One of the features of Cron is the ability to run [Cron jobs](https://betterstack.com/community/guides/linux/cron-jobs-getting-started/) as a specific user.
Sometimes you may even want to create a special user with limited privileges
just to run Cron jobs. There are two methods how to run cronjob as a specific
user.

[info]
## 🔭 Want to get alerted when your Cron doesn't run correctly?
Go to [Better Stack](https://betterstack.com/uptime/) and start monitoring them in 5 minutes.
[/info]

## Using system crontab

Every Cron has a system-wide crontab. The system crontab is located in
`/etc/crontab`. Here, you can find scheduled system cronjobs. You can run a
custom cronjob by adding a new line in the `/etc/crontab` file and specifying
the user who will run the command as in the following example.

```bash
#m  h dom mon dow user      command
*   *  *   *   *  someuser  echo 'Hello world!'
```

This will echo `Hello world!` in the terminal every minute.

## Using user crontab

The second approach is to create a user-specific crontab and schedule a cronjob
in this crontab. First, log in as the select user.

```bash
su someuser
```

Then create or open user-specific crontab.

```bash
crontab -e
```

If the user doesn't have a crontab it will create a new one and ask you to
select your preferred text editor. Select your text editor and proceed to the
next step.

And finally, add a cronjob in this file.

```bash
#m  h dom mon dow  command
*   *  *   *   *   echo 'Hello world!'
```

This will echo `Hello world!` in the terminal every minute.

[ad-uptime]