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 automatically shut down the computer and manage the computing tasks in Linux

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "Linux how to automatically shut down and computing task management", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Linux how to automatically shut down and computing task management" this article.

1. Automatic shutdown script

It is detected at regular intervals, shutting down if a process does not exist, and hibernating if it exists.

Usage:. / script name process name dormancy time

Note: you must have the right to shut down (generally speaking, the root user or the sudoer user)!

Suggested usage: screen. / script name process name hibernation time

# / bin/bash while: do thread_num= `ps-e | grep $1 | wc-l`if [$thread_num-eq 0]; then date > > shutdowntime.log shutdown-h exit else echo "Sleeping $2 second..." Sleep $2 fidone

two。 Calculation task management script

Simple computing task management: detect the number of processes with a certain name, and if not less than the set number, submit the task until the number of processes is equal to the set number; if the number of processes is greater than or equal to the set number, sleep for a certain period of time.

Usage:. / script name, program name, number of tasks, cycles.

It is recommended to run with screen.

#! / bin/bash pro_name=$1task_num=$2cycle_num=$3 i=1while (($i= 23)) | | (($time_hour < 7); then task_num=$core_num # during the period from 23:00 in the evening to 7: 00 in the morning, the task else task_num=$ is fetched according to the number of core on the machine (($core_num / 2)) # only half of the core is used for the task fi at other times

After the execution of all the cycles that should be done, you can also add the command to shut down.

These are all the contents of the article "how to automatically shut down Linux and manage computing tasks". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more 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