How to schedule tasks on Linux using the 'at' command कैसे Linux पर काम अनुसूची के लिए 'में' कमांड का प्रयोग

by Sukrit Dhandhania on May 4, 2009 Sukrit Dhandhania द्वारा 4 मई 2009 पर

लिनक्स

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 cronat . यहाँ 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 अगले हफ्ते

Related Posts: संबंधित पोस्ट:
  • Increase your Linux/Unix Productivity: How to use crontab आपके Linux / Unix उत्पादकता बढ़ाएँ: कैसे crontab का उपयोग
  • Dashboard Widget: MLB Schedule डैशबोर्ड विजेट: MLB अनुसूची
  • How to enable the root user account in Ubuntu Linux कैसे Ubuntu Linux में जड़ उपयोगकर्ता खाते में सक्षम करने के लिए
  • How to stop your Mac from waking up when it should be sleeping कैसे जाग जब यह होना चाहिए सो अपने मैक से रोकने के लिए
  • How to stop Ubuntu from asking for your sudo password कैसे अपने sudo पासवर्ड के लिए पूछ रहा से Ubuntu रोकने के लिए
  • Get Simple Help tutorials just like this one in your email inbox every day - for free! बस अपने ईमेल इनबॉक्स के लिए मुफ्त हर दिन - में यह एक तरह सरल सहायता ट्यूटोरियल जाओ! Just enter your email address below: जरा नीचे अपने ईमेल पते दर्ज करें:

    You can always opt out of this email subscription at any time. तुम हमेशा इस ईमेल सदस्यता से बाहर किसी भी समय विकल्प चुन सकते हैं.

    { 1 trackback } (1) Trackback

    Use the At command in Linux for one-off task scheduling « Linux & Stuff का उपयोग करें लिनक्स में से एक के लिए कमान में कार्य अनुसूचन «लिनक्स एवं सामग्री ऑफ
    05.24.09 at 2:59 pm 2:59 पर 05.24.09

    { 2 comments… read them below or (2 टिप्पणियाँ ... उन्हें या नीचे पढ़ें add one एक जोड़ } )

    1 1 MikeT 05.04.09 at 5:26 am 5:26 पर MikeT 05.04.09 हूँ

    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 हैं).

    2 2 MikeT 05.04.09 at 5:32 am 5:32 पर MikeT 05.04.09 हूँ

    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 एक टिप्पणी छोड़ दो

    You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> आप ये HTML टैग और विशेषताएँ: <a href="" उपयोग title=""> <abbr title=""> <acronym कर सकते हैं <blockquote title=""> <b> cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>