Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Linux System Getting Started Learning: Join cron job in Linux     - Install the latest Eclipse IDE in Ubuntu (Linux)

- SSH mutual trust configuration (Server)

- OpenStack / Dev stack with neutron on Ubuntu 14.04 (Server)

- Encrypted with GnuPG signature to verify the authenticity and integrity of downloaded file (Linux)

- Linux upgrade Glibc (Linux)

- The three-way division of the sorting algorithm Quicksort (Programming)

- curl Usage: Being the first site header and status codes (Server)

- Configure the Linux kernel and use iptables to do port mapping (Linux)

- Installation Enpass secure password manager on Ubuntu (Linux)

- Linux to achieve a simple cp command (Linux)

- Linux non-root user uses less than 1024 ports (Linux)

- Thinking in Java study notes - Access modifiers (Programming)

- Linux Getting Started Tutorial: Ubuntu laptop screen brightness adjustment (Linux)

- How UTorrent download the ISO image from the command line (Linux)

- MySQL replication master and slave structure built (Database)

- PostgreSQL export data dictionary documents (Database)

- Linux port scanning (Linux)

- xCAT install and update software (Linux)

- Java object initialization (Programming)

- Simple Linux file system - df, du, ln (Linux)

  Linux System Getting Started Learning: Join cron job in Linux
  Add Date : 2018-11-21      
  Question: I would like to arrange a scheduled task on my Linux, the task runs periodically at a fixed time. How do I add a cron job in Linux?

cron is a Linux default scheduled tasks. Use cron, you can schedule a program (for example: command or shell scripts) to run periodically or at a specified minute particular time hour, day, week, month, etc. run. cron you arrange different regular maintenance tasks is useful, for example, periodic backups, log rotation, check the file system to monitor disk space, and so on.

Adding cron tasks from the command line

To add a cron task, you can use the command-line tool called crontab.

Enter the following command creates a new cron task running in the current user.

$ Crontab -e
If you want other users to run cron jobs, enter the following command.

$ Sudo crontab -u < username > -e
You will see a text editor window, where you can add or edit the cron task. Nono default editor.

The format of each cron task below.

< Minute > < hr > < day > < month > < weeks > < command >
The first five elements define the schedule for the task, the last element is the full path of the command or script.

Here are some examples of cron tasks.

* * * * * /home/dan/bin/script.sh: Every minute run.
0 * * * * /home/dan/bin/script.sh: run every hour.
0 0 * * * /home/dan/bin/script.sh: daily 0:00 run.
0 9,18 * * * /home/dan/bin/script.sh: runs daily 9AM and 6PM.
0 9-18 * * * /home/dan/bin/script.sh: at 9AM to 6PM every hour of operation.
0 9-18 * * 1-5 /home/dan/bin/script.sh: Monday to Friday 9AM to 6PM hour operation.
* / 10 * * * * /home/dan/bin/script.sh: run every 10 minutes.
Once you have completed the above setup steps, press Ctrl + X to save and exit the editor. At this time, the new scheduled task should have been activated.

To view existing scheduled tasks, use the following command:

$ Crontab -l
Add Scheduled Task from the GUI

If you are in Linux desktop environment, you can use the more friendly GUI front end crontab to add or add a cron task.

In Gnome desktop, there is a Gnome Schedule (gnome-schedule package).

In the KDE desktop, there is a Task Scheduler (kcron package).
- SaltStack installation and testing (Server)
- Binary search is really easy as you think you do (Programming)
- Yii PHP Framework Getting Started tutorial (Linux)
- CentOS6 installation configuration rsh (Server)
- Java how to achieve bubble sort the problem Arraylist (Programming)
- Observation network performance tools for Linux (Linux)
- xCAT deployment (Linux)
- How to use Linux to download music from Grooveshark (Linux)
- How to determine whether the Linux server was hacked (Linux)
- The difference between statement and preparedStatement of the jdbc (Database)
- Installation JDK 1.8 under CentOS7 (Linux)
- File encryption and decryption of Linux security mechanisms (Linux)
- How to Install Node.js in CentOS 7 (Linux)
- Oracle 11g users to create, authorize and import dmp file (Database)
- Thinking in Java study notes - Generics (Programming)
- Oracle to read and modify the data block process (Database)
- MySQL binlog automatic cleanup script (Database)
- APT-GET commonly used Linux command (Linux)
- Linux System Getting Started Learning: Disable Ubuntu Apport internal error reporting procedures (Linux)
- CentOS 6.4 Telecom ADSL dial-up network configuration (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.