# How to save cron job output to file?

Any [cron job](https://betterstack.com/community/guides/linux/cron-jobs-getting-started/) can generate output. It may be log or error messages. Regardless of
the nature of the output, you may want to save this output to a file. This can
be done using the `>` operator.

[info]
## 🔭 Want to get alerted when your Cron doesn’t run correctly?
Go to [Better Stack](https://betterstack.com/uptime/) and start monitoring in 5 minutes.
[/info]

## Saving cron job output to file

To save the output from the cron job running the shell script to a file, use the
following command:

```bash
*   *  *   *   *   /bin/backup.sh > /bin/file.txt 2>&1
```

Let's break down this cron job:

- `/bin/backup.sh > /bin/file.txt` states that the output from `/bin/backup.sh`
  will be redirected and saved in the `/bin/file.txt`
- `2>&1` states that the standard error (`2>`) is redirected to the same file
  descriptor that is pointed by standard output (`&1`)

[ad-uptime]