In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the usage of Linux crontab". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of Linux crontab".
Crontab
When using cron, we often have multiple processes when a command is started again because it takes too long to run.
You can use flock, such as:
* / 1 * flock-xn / opt/app/nginx/test_repo/app/tasks/checkPaymentUrl.lock-c 'sudo-u apache php / opt/app/nginx/test_repo/app/console Payment checkPaymentUrl > > / dev/null 2 > & 1'
When multiple processes may perform operations on the same data, they need to ensure that other processes are not operating as well, so as not to damage the data.
Typically, such a process uses a "lock file", that is, to create a file to tell other processes that they are running, and to assume that there is a process working with the same data if the file is detected. The problem is that the process accidentally dies and does not clean up the lock file, so it can only be cleaned up manually by the user.
Parameters.
A shared lock is acquired. During the time when a shared lock is set on the FD directed to a file without releasing the lock, the request of other processes to set an exclusive lock on the FD directed to this file fails, while the request of other processes to set the shared lock on the FD directed to this file will succeed. -XQuery copyright: acquires an exclusive lock, or write lock, which is the default. -Umam Murray unlock: release the lock manually. Normally, it is not necessary. When FD is closed, the system will automatically unlock the lock. This parameter is used when some script commands need to be executed asynchronously and some can be executed synchronously. -nonblock: non-blocking mode, which returns 1 instead of waiting when the lock acquisition fails. -w,-- wait,-- timeout seconds: sets the blocking timeout, exits blocking mode when the set number of seconds is exceeded, returns 1, and continues with subsequent statements. -o,-- close: means that the FD that sets the lock is closed before the command is executed, so that the child process of the command does not keep the lock. -c,-- command command: execute subsequent statements in shell.
Example
Crontab uses flock to prevent repeated execution
023 * (flock-xn. / test.lock-c "sh / root/test.sh") #-n Thank you for reading for the non-blocking mode. The above is the content of "the usage of Linux crontab". After the study of this article, I believe you have a deeper understanding of the usage of Linux crontab, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.