banner 728x90

Create and manage CRON tasks

In Mobile Web Development 28 views
banner 728x90

Interval or planned task execution is used everywhere in IT, the most obvious case is transaction batching. For web developers like myself, the most obvious use case is performing CRON tasks for this blog, including polling for scheduled blog post publication and a variety of other tasks. I also use crontab on my local computer to update remote git archives before I go to work every morning so that I always work from the most recent code. Let's take a brief look at the use of crontab to create and manage CRON tasks!

To create, edit, or delete CRON tasks, use the crontab command. You can view and edit existing tasks and create new tasks with the following command:

 crontabe 

The previous command will show you a screen with existing CRON tasks if they exist:

# Example
01 * * * * /path/to/script-to-run.sh

The format for task planning is:

# * * * * * /path/to/script-to-run.sh
(minute) (hour) (day of the month) (month of the year) (day of the week) (script)

I recommend to create one executable file for each task – it keeps complex logic outside of the [crunching editing interface and avoids reinstallation when editing in crontab.

You can also set your crontab jobs to run every . For example, you can specify that a task is performed every 30 minutes of the hour with:

# Runs on the 30th minute of every month
30 * * * * /path/to/script-to-run.sh

You can use the format * / to perform a CRON task with small intervals:

# Performs a task every 15 minutes
* / 10 * * * * /path/to/script-to-run.sh

# Performs a task every 2 hours
0 * / 2 * * * /path/to/script-to-run.sh

You can also select exact values ​​with commas & # 39; s:

# Perform task only on weekdays
* * * * mon, tue, wo, thu, fri /path/to/script-to-run.sh

Delete or delete a CRON task by simply removing the rule from the crontab interface. One of the beauties of crontab is that the whole is refreshed when tasks are updated.

The automatic execution of tasks based on time is an incredibly useful option. I had always seen CRON as a website option, but having local functionality is also incredibly useful.


banner 728x90
author
Author: 
    Script & Style Show: Episode 1: Marc Grabanski
    Script & Style Show: Episode 1: Marc Grabanski
    During this second episode of the Script
    AWS AppSync region expansion and new functions for API keys
    AWS AppSync region expansion and new functions for API keys
    AWS AppSync, a managed GraphQL service with
    What is the best time to involve your mobile app users?
    What is the best time to involve your mobile app users?
    When talking to customers about mobile analysis,
    How to make a Twitter bot with Node.js
    How to make a Twitter bot with Node.js
    Twitter bots have been in the news

    Leave a reply "Create and manage CRON tasks"

    Must read×

    Top