Toggle navigation
TechnoWikis.com
Email or Username
Password
Remember
Login
Register
|
I forgot my password
All Activity
Questions
Hot!
Pending
Ask a Question
Privacy Policy
Contact
Cron and Crontab - Manage time in Linux
Home
Tutorials
Linux / Unix
Cron and Crontab - Manage time in Linux
(adsbygoogle = window.adsbygoogle || []).push({});
+5
votes
182
views
Cron and Crontab - Manage time in Linux
asked
Jun 23, 2019
in
Linux / Unix
by
backtothefuture
(
552k
points)
reopened
Jun 23, 2019
|
182
views
answer
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Add answer
Cancel
1
Answer
+3
votes
Best answer
Cron has the ability to execute processes in the background, transparent to the user, can be configured and then run without the user intervening.
It is widely used in servers to perform maintenance, backup or specific tasks of some web.
To create cron command we can use the terminal window and write
crontab
-e
The first time it is executed, it will request that we indicate which will be the default text editor to use vi, nano or other.
Here we will add our crontab rules.
The rules or crontab command has the following scheme
mh sun dow user command
m
- express minutes in which the script will be executed, the value goes from 0 to 59
h
- express the exact time, in 24 hour format, the values ​​go from 0 to 23, being 0 at 12:00 midnight.
sun
- express day of the month, you can specify 10 if you want to run every day 10 of the month
dow
- expresses the day of the week, can be numeric (0 to 7, where 0 and 7 are Sunday) or the first 3 letters of the day in English: mon, tue, wed, thu, fri, sat, sun.
uer
- defines the user that will execute the command, can be root, or another different user as long as he has permission to execute the script.
command
- is the command or absolute path of the script to be executed, example: /home/user/script.sh, if it calls a script, it must be executable.
So for example you can create a monkey
Create a backup every day at 10:30
30 10 * * * user / home / user / backup.sh
Update the operating system on Fridays at 1:00
00 01 * * 6 root apt-get -y update root user
Another variant for the same would be to use the name of the day Friday (Friday)
00 01 * * fri root apt-get -y update root user
A more complete and complex command
Every August 30th at 11:30 PM carry out server maintenance tasks
30 23 30 08 * user /home/user/servermaintenance.sh
The same can be configured in all server control panels.
For example, from the Directadmin control panel, we have a visual interface to create the cron command
It is also possible to create cron command from Cpanel in a very similar way to the previous one
If we have a website, it can be used to perform tasks such as updating the web, performing maintenance tasks on the database, performing automatic backups, sending emails such as:
Every day at midnight send newsletter to users
00 00 * * * user /home/user/mydomain.com/newsletter.php
We are going to create an example to synchronize with the Rsync software a local directory with a directory on a server that we assume we are connected to
00 21 * * * rsync -avz --password-file = / etc / rsync.secret / home / dir-local / myuser @ ipdelserver :: dir-emoto
answered
Jun 23, 2019
by
stackoverflow
(
3.5m
points)
edited
Jun 23, 2019
ask related question
comment
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Add comment
Cancel
Related questions
+5
votes
1
answer
Manage expiration and expiration of user password in Linux
asked
Nov 2, 2019
in
Linux / Unix
by
backtothefuture
(
552k
points)
|
275
views
+5
votes
1
answer
How to set server time and hardware in CentOS Linux
asked
Nov 4, 2019
in
Linux / Unix
by
backtothefuture
(
552k
points)
|
244
views
+5
votes
1
answer
Whowatch: Monitor Linux users and processes in real time
asked
Oct 7, 2019
in
Linux / Unix
by
backtothefuture
(
552k
points)
|
301
views
+3
votes
1
answer
How to install and use KVM to manage Cloud images on Linux
asked
Nov 17, 2019
in
Linux / Unix
by
backtothefuture
(
552k
points)
|
260
views
+4
votes
1
answer
How to create Jobs without Cron in Linux
asked
Jun 27, 2023
in
Linux/Unix
by
backtothefuture
(
552k
points)
|
64
views
Sponsored articles cost $40 per post. You can contact us via
Feedback
All categories
Tutorials
7.5k
Microsoft
1.9k
Android
1.4k
Security
120
Linux / Unix
543
Internet
757
Virtualization
104
Apple
611
Networks
64
Other Devices
321
Other Applications
184
Hardware
19
Development
53
Digital Marketing
47
Databases
14
Graphic Design
30
Guides
794
GraphicDesign
54
Networking
4
PlayStation
186
Gaming
55
Linux/Unix
85
Manzana
33
Otherdevices
38
Otherapps
49
Digitalmarketing
39
Safety
1
Developing
2
Help
685
Social Networks
34
Android Tutorial
549
iPhone Tutorial
267
News
17
Social
6
Phone
11
Telephone
9
Applications
167
Smartphones
3
Cell Phones
11
Applications
25
Travels
6
Photo
21
Education
18
Games
25
Internet
14
Music
8
Technique
10
Video
6
Windows
5
Apple
2
Cell Phones
3
TikTok
216
Trips
2
House
1
Operating System
5
Tips & Tricks
892
Solutions
6
Tutorials
3
FAQ
1
Applications
5
Cell Phones
2
Tutorials
4
Computers
6
Tutoriales
2
8
Technology
2
In Computers
1
In Applications
2
Tutorials Tutorials
9
Applications Applications
25
Aplicaciones Applications
4
Devices Devices
5
Tutoriales Tutorials
1
Tutorials u00a0 Tutorials
2
Applications u00a0 Applications
2
Devices u00a0 Devices
1
OS OS
1
Etc Etc
2
Most popular questions within the last 30 days
Please leave a comment about whether the solution works or not (with device model)
[X]Close
10,659
questions
10,791
answers
510
comments
3
users