Quick startcrontab
Command, used to schedule cron jobs
Cron jobs are jobs that are scheduled to run at specific intervals. You might make the command execute an operation every hour, every day, or every 2 weeks. Or on the weekend. They are very powerful, especially on servers that perform maintenance and automation.
Thiscrontab
command is the entry point for using cron jobs.
The first thing you can do is to research which cron jobs you have defined:
crontab -l
You may not have someone like me:
run
crontab -e
Edit the cron job and add a new job.
By default, it will be opened with the default editor, which is usuallyvim
. I likenano
In addition, you can use the following line to use other editors:
EDITOR=nano crontab -e
Now you can add a row for each cron job.
The syntax for defining cron jobs is a bit scary. This is why I usually use websites to help me generate it without errors:https://crontab-generator.org/
You select a time interval for the cron job, and then type the command to be executed.
I choose to run at/Users/flavio/test.sh
Every 12 hours. This is the crontab line I need to run:
* */12 * * * /Users/flavio/test.sh >/dev/null 2>&1
I runcrontab -e
:
EDITOR=nano crontab -e
Then add the line and pressctrl-X
then pressy
save.
If all goes well, then the cron job will be created:
After this is done, you can view the list of active cron jobs by running the following command:
crontab -l
You can delete running cron jobscrontab -e
Again, delete the line and exit the editor:
Thiscrontab
This command can be used in Linux, macOS, WSL and wherever you have a UNIX environment
Download mine for freeLinux Command Manual
More cli tutorials:
- Bash shell
- Introduction to Bash Shell Script
- Fish shell
- Shell, monitor file content
- How to exit Vim
- UNIX editor
- UNIX file system commands
- Unix Shell Tutorial
- How to set an alias in macOS or Linux Shell
- Homemade practical guide
- How to fix XCRUN invalid active developer path error in MacOS
- Getting Started
- Introduction to Linux
- How to find the process that is using the port
- Linux command: mkdir
- Linux command: cd
- Linux command: pwd
- Linux command: rmdir
- Linux command: ls
- Linux command: mv
- Linux command: cp
- Linux commands: less
- Linux command: tail
- Linux command: touch
- Linux command: cat
- Linux command: find
- Linux command: ln
- Linux command: ps
- Linux command: echo
- Linux command: top
- Linux command: kill
- Linux command: killall
- Linux command: alias
- Linux command: job
- Linux command: bg
- Linux command: fg
- Linux command: Type
- Linux command: where
- Linux command: whoami
- Linux command: who
- Linux command: clear
- Linux command: su
- Linux command: sudo
- Linux command: chown
- Linux command: chmod
- Linux command: passwd
- Linux command: open
- Linux command: wc
- Linux commands: history
- Linux command: du
- Linux command: umask
- Linux command: grep
- Linux command: man
- Linux command: uname
- Linux commands: sort
- Linux command: uniq
- Linux command: diff
- Linux command: nohup
- Linux command: df
- Linux command: xargs
- Linux command: gzip
- Linux command: gunzip
- Linux command: ping
- Linux command: traceroute
- Linux command: tar
- Linux command: export
- Linux command: crontab
- Linux command: dirname
- Linux command: base name
- Linux command: printenv
- Linux command: env
- A short guide to the ed editor
- vim short guide
- A brief guide to emacs
- A brief guide to Nano
- Linux, no space left on the device
- How to use Netcat