Scheduling jobs is an essential part of administering Linux servers. निर्धारण नौकरियों लिनक्स सर्वर के प्रशासन का एक अनिवार्य हिस्सा है. We took a look at how to schedule jobs on Linux machine using the हम कैसे लिनक्स का उपयोग मशीन पर काम अनुसूची करने पर एक नज़र लिया cron cron command earlier. पहले कमान. Here's an alternative to cron – at . यहाँ cron के लिए एक विकल्प है - पर. The primary difference between the two is that when you schedule a task using cron it execute repeatedly without the need for rescheduling. दोनों के बीच प्राथमिक अंतर यह है कि तुम एक cron यह पुनर्निर्धारण के लिए की आवश्यकता के बिना बार बार मार का उपयोग कर जब काम अनुसूची. With at , on the other hand, the scheduling of a task is only for a single execution. पर साथ ही, दूसरे हाथ पर, एक काम का निर्धारण एक निष्पादन के लिए ही है. Both of these commands have their use, and I would suggest that you get a good understanding of them both. इन दोनों ने अपने आदेश का उपयोग किया है, और मेरा सुझाव है कि आप उन दोनों की एक अच्छी समझ हो.
Let's look at how to schedule a task to execute only once using the at command. चलो कैसे काम अनुसूची करने के लिए केवल एक बार निष्पादित का उपयोग कर देखो कमान में. First make sure that the at daemon is running using a command like this: पहले सुनिश्चित करें कि डेमॉन पर इस तरह एक कमांड का प्रयोग कर रहा है:
# ps -ef | grep atd Ps #-एफई | grep atd
root 8231 1 0 18:10 ? जड़ 8,231 1 18:10 0? 00:00:00 /usr/sbin/atd 00:00:00 / usr / sbin / atd
If you don't see atd running start it with this command: यदि आप इसे इस आदेश के साथ शुरू नहीं चल atd कर देखें:
# /etc/init.d/atd start # / Etc / init.d / atd शुरू
Once the daemon has been started successfully you can schedule an at task using the two options -f , for the file to be executed, and -v , for the time at which it should be executed. एक बार डेमॉन सफलतापूर्वक शुरू किया गया है आप एक काम पर अनुसूची दो विकल्प च, फ़ाइल के लिए मार डाला होगा, और ध्, जो समय पर उसे मार डाला जाना चाहिए के लिए उपयोग कर सकते हैं. So if you want to execute the shell script shellscript.sh at 6:30 PM you would run the following command: तो अगर आप 6:30 आपको निम्नलिखित कमांड चलाने पर होगा खोल स्क्रिप्ट shellscript.sh निष्पादित करना चाहते हैं:
# at -f shellscript.sh -v 18:30 # में एफ shellscript.sh-v 18:30
Remember that with the at command the script shellscript.sh will execute at 6:30 PM and then the scheduling will disappear. याद रखें कि साथ में स्क्रिप्ट shellscript.sh कमान 6:30 पर निष्पादित और फिर समयबद्धन गायब हो जाएगी. So if this is not what you desire, you are better off using cron . तो अगर यह तुम क्या इच्छा नहीं है, आप अच्छी है cron इस्तेमाल करते हैं.
The at command is pretty clever in that it can take some orders in English if you like. आदेश में बहुत होशियार है कि यह अंग्रेजी में कुछ आदेश ले अगर आप की तरह कर सकते हैं. For example, you can schedule jobs using the following syntax as well: उदाहरण के लिए, आप अच्छी तरह के रूप में निम्नलिखित वाक्य रचना का उपयोग कर रोजगार कार्यक्रम कर सकते हैं:
# at -f shellscript.sh 10pm tomorrow # में एफ shellscript.sh 10 कल
# at -f shellscript.sh 2:50 tuesday # में एफ shellscript.sh 2:50 मंगलवार
# at -f shellscript.sh 6:00 july 11 #-च shellscript.sh 6:00 पर जुलाई 11
# at -f shellscript.sh 2:00 next week # में एफ shellscript.sh 2:00 अगले हफ्ते























{ 1 trackback } (1) Trackback
{ 2 comments… read them below or (2 टिप्पणियाँ ... उन्हें या नीचे पढ़ें add one एक जोड़ } )
If you don't see atd running start it with this command: यदि आप इसे इस आदेश के साथ शुरू नहीं चल atd कर देखें:
# /etc/init.d/atd start # / Etc / init.d / atd शुरू
More correctly, if it isn't running, it probably is not configured to startup when the system is restarted. ज्यादा सही है, अगर यह नहीं चल रहा है, यह शायद कॉन्फ़िगर नहीं है, जब प्रणाली पुनर्प्रारंभ है स्टार्टअप है. Which may also keep the above command from working as expected. जो भी काम कर के रूप में की संभावना से ऊपर कमांड रख सकते हैं. To correct this, use: यह सही है, का उपयोग करें:
# chkconfig atd --level 234 on
# service atd start
and check again to make sure it is running, if it is, continue with the instructions (which are very good BTW). और फिर से चल रहा है यह सुनिश्चित करने के लिए जाँच, अगर यह, अनुदेशों के साथ जारी है (जो कि बहुत अच्छा BTW हैं).
I have another followup for you on use of the at command. मैं के प्रयोग पर आप के लिए एक और follow-up है कमान में.
I've run into situations where I've needed a command run every hour BUT I needed the command to run ONLY if the previous run has completed. मैं स्थितियों जहाँ मैं एक आदेश की जरूरत है मैं आदेश की जरूरत केवल चलाने अगर पिछले भाग पूरा कर लिया है लेकिन हर घंटे दौड़ में भाग लिया है. It might not be hung but it might be very very busy. लेकिन यह नहीं त्रिशंकु बहुत बहुत व्यस्त हो सकता है हो सकता है. I don't mind skipping an hour's execution if the process is still busy. मैं एक घंटे निष्पादन लंघन मन नहीं अगर प्रक्रिया अभी व्यस्त है है.
When this situation arises, I don't use cron, I use 'at' and the last thing I put in my script is the at command itself to resubmit the job for execution. जब यह स्थिति पैदा होती है, मैं cron का उपयोग नहीं, मैं 'में इस्तेमाल' और अंतिम बात मैं अपनी लिपि में डाल करते हैं पर खुद कमान के निष्पादन के लिए काम पुनः भेजें.
Now, even if the job takes three hours, at the top of the following hour, the at command will launch the job as expected without cron jobs bumping into each other. अब, अगर काम तीन घंटे लगते हैं, निम्नलिखित घंटे के शीर्ष पर, आदेश में नौकरी के रूप में cron एक दूसरे में bumping नौकरियां बिना उम्मीद का शुभारंभ करेंगे में.
Yes, there's ways to put the logic into a script for cron to deal with it but that can also be difficult to maintain and not as obvious (to some) as this approach. हाँ तरीके, वहाँ है cron के लिए एक पटकथा में तर्क दिया इसके साथ सौदा है लेकिन वह भी बनाए रखने और स्पष्ट रूप में मुश्किल नहीं किया जा सकता है (कुछ) इस दृष्टिकोण के रूप में.
Leave a Comment एक टिप्पणी छोड़ दो