# cron
### Resources
### [crontab guru](https://crontab.guru/)
*The quick and simple editor for cron schedule expressions by Cronitor*
![[Screen Shot 2022-08-21 at 2.15.57 AM.png]]
### [How I use cron in Linux](https://opensource.com/article/17/11/how-use-cron-linux)
[[2020-01-02]]
Includes a note on **`anacron`** which *performs the same function as crond, but it adds the ability to run jobs that were skipped, such as if the computer was off or otherwise unable to run the job for one or more cycles. ==This is very useful for laptops and other computers== that are turned off or put into sleep mode.*
## Setting up a crontab
RTFM
```bash
man cron
man crontab
```
Edit the crontab file
```bash
crontab -e
```
Configuration example:
```bash
PATH=/usr/local/bin:/usr/bin:/home/ec2-user/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.fzf/bin:/usr/local/sbin:/home/ec2-user/.cargo/bin:/home/ec2-user/gocode/bin:/usr/local/opt/fzf/bin
SHELL=/usr/bin/zsh
[email protected]
# Accumulate all PNL logs at 12:00 (UTC) every Monday
0 12 * * 1 cd /home/ec2-user/tyche && ./scripts/accumulate.sh
```
- The default path is `/usr/bin:/bin`, so you'll want to override it with e.g. the output of `echo $PATH`
- The default shell is `/bin/sh`, so you'll want to override it to e.g. the output of `echo $SHELL`
- `MAILTO` does the obvious thing.
- Visit [crontab guru](https://crontab.guru/) for an easy-to-understand guide to the scheduling syntax at the beginning.
- cron runs commands from the home directory by default; to 'set' the working directory commands, prepend the commands with `cd /path/to/working/directory && `.
See the saved crontab
```bash
crontab -l
```
The cron service checks for files in the `/var/spool/cron` and `/etc/cron.d` directories and the `/etc/anacrontab` file