请选择 进入手机版 | 继续访问电脑版

设为首页 收藏本站
思科社区 关注
思科社区

搜索
热搜: 邮件服务器
查看: 528|回复: 3

【原创】Nexus设备上定时自动任务的使用

[复制链接]
发表于 2020-4-30 13:20:38 | 显示全部楼层 |阅读模式
本帖最后由 liu.zhimin 于 2020-4-30 13:25 编辑

前言:大家日常生活中可能会遇到如下需求,需要凌晨定时去关闭某一个端口,某个时间又需要开启这个端口,此时大家可以使用Nexus平台特有的feature scheduler

配置方法:
[td]
Command or Action
Purpose
Step 1
[size=1.4]configure terminal
Example:switch# configure terminalswitch(config)#
[size=1.4]Enters global configuration mode.
Step 2
[size=1.4][no] feature scheduler
Example:switch(config)# feature scheduler
[size=1.4]Enables or disables the scheduler.
  1. <article class="topic concept nested2" aria-labelledby="ariaid-title20" lang="en-US" id="concept_003FB5F6824B4DD2B208990134B4C0A2" style="border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: CiscoSans, Arial, sans-serif; vertical-align: baseline; color: rgb(88, 88, 91); background-color: rgb(255, 255, 255);"><h3 class="title topictitle3" id="ariaid-title20" style="margin-bottom: 8px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: 400; font-stretch: inherit; font-size: 2.1rem; line-height: 1.25em; font-family: inherit; vertical-align: baseline; color: rgb(57, 57, 59);">Creating a Scheduler Job</h3><section class="body conbody" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font: inherit; vertical-align: baseline;"><p class="p" style="margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.4rem; line-height: 1.4em; font-family: inherit; vertical-align: baseline;">This example shows how to create a scheduler job that saves the running configuration to a file in the bootflash. The job then copies the file from the bootflash to a TFTP server (creates the filename using the current timestamp and switch name):</p><pre class="pre codeblock" style="margin-bottom: 20px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; max-width: 100%; overflow-x: auto; overflow-y: visible !important;"><code style="margin-top: 12px; margin-bottom: 12px; border: 0px; font: inherit; vertical-align: baseline;">switch# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">configure terminal</b></kbd>
  2. switch(config)# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">scheduler job name backup-cfg</b></kbd>
  3. switch(config-job)# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">copy running-config
  4. tftp://1.2.3.4/$(SWITCHNAME)-cfg.$(TIMESTAMP) vrf management</b></kbd>
  5. switch(config-job)# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">end</b></kbd>
  6. switch(config)#

  7. </code></pre></section><nav role="navigation" class="related-links" style="border: 0px; font: inherit; vertical-align: baseline;"></nav></article><article class="topic concept nested2" aria-labelledby="ariaid-title21" lang="en-US" id="concept_DE12A29ADF6A45AB9DE5291DD67DFCBA" style="border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: CiscoSans, Arial, sans-serif; vertical-align: baseline; color: rgb(88, 88, 91); background-color: rgb(255, 255, 255);"><h3 class="title topictitle3" id="ariaid-title21" style="margin-bottom: 8px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: 400; font-stretch: inherit; font-size: 2.1rem; line-height: 1.25em; font-family: inherit; vertical-align: baseline; color: rgb(57, 57, 59);">Scheduling a Scheduler Job</h3><section class="body conbody" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font: inherit; vertical-align: baseline;"><p class="p" style="margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.4rem; line-height: 1.4em; font-family: inherit; vertical-align: baseline;">This example shows how to schedule a scheduler job called backup-cfg to run daily at 1 a.m.:</p><pre class="pre codeblock" style="margin-bottom: 20px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; max-width: 100%; overflow-x: auto; overflow-y: visible !important;"><code style="margin-top: 12px; margin-bottom: 12px; border: 0px; font: inherit; vertical-align: baseline;">switch# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">configure terminal</b></kbd>
  8. switch(config)# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">scheduler schedule name daily</b></kbd>
  9. switch(config-if)# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">job name backup-cfg</b></kbd>
  10. switch(config-if)# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">time daily 1:00</b></kbd>
  11. switch(config-if)# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">end</b></kbd>
  12. switch(config)#

  13. </code></pre></section><nav role="navigation" class="related-links" style="border: 0px; font: inherit; vertical-align: baseline;"></nav></article><article class="topic concept nested2" aria-labelledby="ariaid-title22" lang="en-US" id="concept_C744549A0FC446A29A3D55B631944BD5" style="border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: CiscoSans, Arial, sans-serif; vertical-align: baseline; color: rgb(88, 88, 91); background-color: rgb(255, 255, 255);"><h3 class="title topictitle3" id="ariaid-title22" style="margin-bottom: 8px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: 400; font-stretch: inherit; font-size: 2.1rem; line-height: 1.25em; font-family: inherit; vertical-align: baseline; color: rgb(57, 57, 59);">Displaying the Job Schedule</h3><section class="body conbody" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font: inherit; vertical-align: baseline;"><p class="p" style="margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.4rem; line-height: 1.4em; font-family: inherit; vertical-align: baseline;">This example shows how to display the job schedule:</p><pre class="pre codeblock" style="margin-bottom: 20px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; max-width: 100%; overflow-x: auto; overflow-y: visible !important;"><code style="margin-top: 12px; margin-bottom: 12px; border: 0px; font: inherit; vertical-align: baseline;">switch# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">show scheduler schedule</b></kbd>
  14. Schedule Name : daily
  15. ---------------------------
  16. User Name : admin
  17. Schedule Type : Run every day at 1 Hrs 00 Mins
  18. Last Execution Time : Fri Jan 2 1:00:00 2013
  19. Last Completion Time: Fri Jan 2 1:00:01 2013
  20. Execution count : 2
  21. -----------------------------------------------
  22. Job Name Last Execution Status
  23. -----------------------------------------------
  24. back-cfg Success (0)
  25. switch#

  26. </code></pre></section><nav role="navigation" class="related-links" style="border: 0px; font: inherit; vertical-align: baseline;"></nav></article><article class="topic concept nested2" aria-labelledby="ariaid-title23" lang="en-US" id="concept_51F3F3C087674DDD8107495DB63A8A7D" style="border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; line-height: inherit; font-family: CiscoSans, Arial, sans-serif; vertical-align: baseline; color: rgb(88, 88, 91); background-color: rgb(255, 255, 255);"><h3 class="title topictitle3" id="ariaid-title23" style="margin-bottom: 8px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: 400; font-stretch: inherit; font-size: 2.1rem; line-height: 1.25em; font-family: inherit; vertical-align: baseline; color: rgb(57, 57, 59);">Displaying the Results of Running Scheduler Jobs</h3><section class="body conbody" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font: inherit; vertical-align: baseline;"><p class="p" style="margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.4rem; line-height: 1.4em; font-family: inherit; vertical-align: baseline;">This example shows how to display the results of scheduler jobs that have been executed by the scheduler:</p><pre class="pre codeblock" style="margin-bottom: 20px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; max-width: 100%; overflow-x: auto; overflow-y: visible !important;"><code style="margin-top: 12px; margin-bottom: 12px; border: 0px; font: inherit; vertical-align: baseline;">switch# <kbd class="userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline;"><b class="ph userinput" style="margin-top: 12px; margin-bottom: 12px; border: 0px; font-style: inherit; font-variant: inherit; font-stretch: inherit; font-size: 1.6rem; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);">show scheduler logfile</b></kbd>
  27. Job Name : back-cfg Job Status: Failed (1)
  28. Schedule Name : daily User Name : admin
  29. Completion time: Fri Jan 1 1:00:01 2013
  30. --------------------------------- Job Output ---------------------------------
  31. `cli var name timestamp 2013-01-01-01.00.00`
  32. `copy running-config bootflash:/$(HOSTNAME)-cfg.$(timestamp)`
  33. `copy bootflash:/switch-cfg.2013-01-01-01.00.00 tftp://1.2.3.4/ vrf management `
  34. copy: cannot access file '/bootflash/switch-cfg.2013-01-01-01.00.00'
  35. ==============================================================================
  36. Job Name : back-cfg Job Status: Success (0)
  37. Schedule Name : daily User Name : admin
  38. Completion time: Fri Jan 2 1:00:01 2013
  39. --------------------------------- Job Output ---------------------------------
  40. `cli var name timestamp 2013-01-02-01.00.00`
  41. `copy running-config bootflash:/switch-cfg.2013-01-02-01.00.00`
  42. `copy bootflash:/switch-cfg.2013--01-02-01.00.00 tftp://1.2.3.4/ vrf management `
  43. Connection to Server Established.
  44. [ ] 0.50KBTrying to connect to tftp server......
  45. [###### ] 24.50KB
  46. TFTP put operation was successful
  47. ==============================================================================
  48. switch#
  49. </code></pre><div><code style="margin-top: 12px; margin-bottom: 12px; border: 0px; font: inherit; vertical-align: baseline;">
  50. </code></div></section></article>
复制代码


  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
平均得分5 (1 评价)
发表于 2020-4-30 17:16:30 | 显示全部楼层
命令部分,这都 看不清啊,能修改一下吗?

  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
平均得分4 (1 评价)
发表于 2020-4-30 18:06:49 | 显示全部楼层
完全没法看啊。。。。
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
平均得分4 (1 评价)
发表于 2020-5-6 11:02:19 | 显示全部楼层
牛b,但是看不懂,
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5
平均得分0 (0 评价)
您需要登录后才可以回帖 思科 CCO 登录 | 思科 CCO 注册   

本版积分规则

Archiver | 思科社区  

GMT+8, 2020-5-26 13:17 , Processed in 0.102459 second(s), 36 queries .

京ICP备11014401号-17

© 2020 思科系统.版权所有 重要声明 | 保密声明 | 隐私权政策 | 商标 |

快速回复 返回顶部 返回列表