forked from docs/doc-exports
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com> Co-authored-by: weihongmin1 <weihongmin1@huawei.com> Co-committed-by: weihongmin1 <weihongmin1@huawei.com>
26 lines
4.4 KiB
HTML
26 lines
4.4 KiB
HTML
<a name="obs_11_0034"></a><a name="obs_11_0034"></a>
|
|
|
|
<h1 class="topictitle1">Configuring Scheduled Tasks Using the Crontab Command</h1>
|
|
<div id="body1545109772221"><div class="section" id="obs_11_0034__section146005674214"><h4 class="sectiontitle">Scenario</h4><p id="obs_11_0034__p811715102429">Go to the <strong id="obs_11_0034__b196642317323">/root</strong> directory at 21:30 every day and upload the <strong id="obs_11_0034__b1358118115364">/src/src1</strong> folder to bucket <strong id="obs_11_0034__b184777156363">obs://bucket-test</strong> in the incremental mode.</p>
|
|
</div>
|
|
<div class="section" id="obs_11_0034__section16839141103914"><h4 class="sectiontitle">Prerequisites</h4><p id="obs_11_0034__p1733316613910">You have properly enabled the scheduled crond service in the Linux OS.</p>
|
|
<div class="note" id="obs_11_0034__note1681514816414"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_11_0034__p16815483419">Run the <strong id="obs_11_0034__b199373583618">service crond status</strong> command to check whether the service is enabled.</p>
|
|
</div></div>
|
|
</div>
|
|
<div class="section" id="obs_11_0034__section13314111314402"><h4 class="sectiontitle">Procedure</h4><ol id="obs_11_0034__ol1088611368423"><li id="obs_11_0034__li48864366429"><span>Run the <strong id="obs_11_0034__b426701719579">crontab -e</strong> command to open the configuration file for setting a scheduled task.</span></li><li id="obs_11_0034__li988683674212"><span>Enter the Insert mode to edit the configuration file.</span><p><pre class="screen" id="obs_11_0034__screen3265933142316">30 21 * * * cd /root && nohup ./obsutil cp /src/src1 obs://bucket-test -r -f -u &>obsutil_crond.log &</pre>
|
|
<div class="note" id="obs_11_0034__note54021727165315"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_11_0034__p1394918291536">Assume that the obsutil tool is in the <strong id="obs_11_0034__b16873104519368">/root</strong> directory. The preceding configuration is described as follows: Go to the <strong id="obs_11_0034__b1735019222480">/root</strong> directory at 21:30 every day, upload the <strong id="obs_11_0034__b113901340164810">/src/src1</strong> folder to bucket <strong id="obs_11_0034__b343284811485">obs://bucket-test</strong> in incremental mode, and redirect the command output to the <strong id="obs_11_0034__b186991139185117">obsutil_crond.log</strong> file in the <strong id="obs_11_0034__b158010442511">/root</strong> directory.</p>
|
|
</div></div>
|
|
</p></li><li id="obs_11_0034__li118861836194214"><span>Press <strong id="obs_11_0034__b1633191919527">Esc</strong> to exit the Insert mode. Then input <strong id="obs_11_0034__b1673482145319">:wq</strong> and press <strong id="obs_11_0034__b18489211242">Enter</strong> to save the configuration and exit.</span></li><li id="obs_11_0034__li18604552205515"><span>Run the <strong id="obs_11_0034__b20353123555816">crontab -l</strong> command to check whether the scheduled task is configured successfully.</span></li></ol>
|
|
</div>
|
|
<div class="section" id="obs_11_0034__section14418131348"><h4 class="sectiontitle">FAQs</h4><ol id="obs_11_0034__ol3240639153512"><li id="obs_11_0034__li1324013916355">How do I determine whether a scheduled task is being executed?<ul id="obs_11_0034__ul12144161133615"><li id="obs_11_0034__li1414413118365">Run the <strong id="obs_11_0034__b105331644662">tail /var/log/cron</strong> command to view the latest scheduled task execution records.</li><li id="obs_11_0034__li1614410117361">Run the <strong id="obs_11_0034__b1666117151272">ps -ef | grep obsutil</strong> command to check whether obsutil is being executed.</li></ul>
|
|
</li><li id="obs_11_0034__li414410153619">How do I forcibly stop an ongoing scheduled task?<ol type="a" id="obs_11_0034__ol10112155844217"><li id="obs_11_0034__li2112105874218">Run the <strong id="obs_11_0034__b2953121990">ps -ef | grep obsutil</strong> command to check the process of obsutil.</li><li id="obs_11_0034__li101122058174214">Run the <strong id="obs_11_0034__b1617118162317">kill -9 </strong><em id="obs_11_0034__i1114272042318">PID</em> command to forcibly stop the process, where <em id="obs_11_0034__i831643312238">PID</em> indicates the queried process ID.</li></ol>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_11_0033.html">Best Practices</a></div>
|
|
</div>
|
|
</div>
|
|
|