Get the App
SLTechnology News&Howtos  ›  Servers  › 

How Linux executes shell script to complete task plan

Shulou Source: shulou.com Published: 2022-06-01 03:00:14 09月22日 Update

Editor to share with you how Linux executes the shell script to complete the task plan. I hope you will get something after reading this article. Let's discuss it together.

As we all know, the current linux running task plan is generally realized with the help of crontab task planning. However, the default minimum unit of this task plan is minutes, that is, the smallest unit is executed once a minute, so if we need to execute it in seconds, it cannot be directly implemented.

We have come into contact with sleep and script running in the background before, so this can come in handy.

1. Write a shell and throw it into the background to run

2Jing shell writes an endless loop, executes the required commands, and the number of seconds between sleep. In this way, it can be executed in seconds.

For example, we print time every second to the / tmp/date.txt file, and the date.sh script is as follows:

#! / bin/bashwhile:; doecho `date` > > / tmp/date.txt sleep 1done

Throw the script in the background to run:

Nohup / home/shell/date.sh &

Of course, it is also possible to set up a virtual terminal for execution with the help of screen, a tool that individuals prefer.

After reading this article, I believe you have a certain understanding of "Linux how to execute the shell script to complete the task plan". If you want to know more about it, welcome to follow the industry information channel, thank you for reading!

Tags: Tasks scripts units background runs minimum articles well known individuals commands done tools ideas files time more usefulness knowledge terminals industries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi MySQL OPPO Reno Shulou Information Shulou Technology