Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement timed tasks in shell

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces shell how to achieve timing tasks, the article is very detailed, has a certain reference value, interested friends must read it!

‍ #! / bin/bash

# Daily schedule

HivePath=/opt/hive/bin/hive

DayDate= `date-d "5 day ago" +% Y% m% d`

# user list (day) user_list_day location: / unicom/CDD/W001

$hivePath-e "use unicom_demo;ALTER TABLE user_list_day ADD IF NOT EXISTS PARTITION (day='$dayDate') LOCATION'/ unicom/CDD/W001/$dayDate';"

# user's online time habit tag (day) user_time_day location: / unicom/CDD/W002

$hivePath-e "use unicom_demo;ALTER TABLE user_time_day ADD IF NOT EXISTS PARTITION (day='$dayDate') LOCATION'/ unicom/CDD/W002/$dayDate';"

For tasks that have to be run every day, you can write a script and put it in a scheduled task to run, so as to avoid performing it manually every day, and scheduled tasks need to be put into crontab.

Inside, enter the crontab-e command to edit the tasks that need to be executed regularly. The first five statements are divided into minutes, hours, days, months and weeks, separated by spaces, followed by

The path where the script is located and the path to the log, as follows

0 17 * sh / opt/ltftp/script/month_table2.sh > > / opt/ltftp/script/month_table2.log

It means to execute at 5: 00 p. M. every day.

The above is all the contents of the article "how to achieve scheduled tasks in shell". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report