Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

syntax crontab

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  *  user command to be executed
example :
# 50 12 * * * ----- run every day at 12.50

# */5 * * * * ----- run every 5 minutes
Comment

crontab example

crontab -e						# to edit (then 'i': insert, ':wq!': save and quit)
10 * * * * /bin/sh backup.sh    # every hour at 10"
0 */4 * * * /bin/sh backup.sh   # every 4 hours at 0"
0 9-17 * * * /bin/sh backup.sh  # every hour at 0" between 9 and 17
0 2 * * * /bin/sh backup.sh     # daily at 2am
0 0 * * MON /bin/sh backup.sh   # every Monday at 0am
0 0 * * 1-5 /bin/sh backup.sh   # daily from Monday to Friday at 0am
0 0 * * 0 /bin/sh backup.sh     # weekly on Sunday
0 0 1 * * /bin/sh backup.sh     # monthly (1rst day at 0am)
0 0 1 */3 * /bin/sh backup.sh   # every quarter (1rst day at 0am)
0 0 1 1 * /bin/sh backup.sh     # yearly (01/01)
Comment

crontab -l

.---------------- minute (0 - 59) 
|  .------------- hour (0 - 23)
|  |  .---------- day of month (1 - 31)
|  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... 
|  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat 
|  |  |  |  |
*  *  *  *  *  command to be executed
Comment

cron crontab

# Adding tasks easily
echo "@reboot echo hi" | crontab

# Open in editor
crontab -e

# List tasks
crontab -l [-u user]
Comment

crontab syntax

.---------------- minute (0 - 59) 
|  .------------- hour (0 - 23)
|  |  .---------- day of month (1 - 31)
|  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... 
|  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7)  OR sun,mon,tue,wed,thu,fri,sat 
|  |  |  |  |
*  *  *  *  *  command to be executed
Comment

*/1 in crontab

*/1 means exactly the same as *
Comment

PREVIOUS NEXT
Code Example
Shell :: bash get line from file 
Shell :: laravel nginx 404 not found 
Shell :: git add only c files 
Shell :: using screen in wsl 
Shell :: --no-check-certificate while running a script 
Shell :: get first 10 processes linux 
Shell :: bash for tuple 
Shell :: ghc change version 
Shell :: git flow feature finish without deleting branch 
Shell :: wc command 
Shell :: E: Unable to locate package rvm 
Shell :: open download folder in mac 
Shell :: Create htpasswd file for nginx (without apache) 
Shell :: 200 response .htaccess 
Shell :: make diff git as commit 
Shell :: git submodule update init no url found 
Shell :: commit history 
Shell :: How to show date and complete time on the Ubuntu Top Panel 
Shell :: View a Particular Commit in git command 
Shell :: how to install mongodb database in ubuntu version 
Shell :: how to open a iso file in linux 
Shell :: kali virtualbox guest additions check version 
Shell :: check login info on mac os 
Shell :: pyqt designer for linux 
Shell :: pacman arch 
Shell :: install jitsi on ubuntu 
Shell :: bash command change time 
Shell :: install wine in ubuntu 20.04 
Shell :: git initial commit 
Shell :: cordova-plugin-facebook4 update 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =