码迷,mamicode.com
首页 > 系统相关 > 详细

shell编程

时间:2018-08-05 00:35:25      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:chm   localhost   查看   local   inux   readonly   shell   pass   创建文件   

集合各种linux命令,实现某个功能,常用于自动化运维等。

shell编程

  1. 创建文件
    [root@localhost test1]# cd /opt/
    [root@localhost opt]# vim shell.sh
  2. 编写脚本文件
    • 首行添加#!/bin/bash
    • 接着编写内容
        echo "please input your name:"
        read uname
        echo "input your password:"
        read upwd
        echo "name:$uname, pwd:$upwd"
    
        #readonly name="py"
    
        #defined variale
    
        name="ppy"
        unset name
  3. 修改文件权限
    [root@localhost opt]# chmod a+x shell.sh
  4. 检查脚本语法
    bash -n shell.sh
  5. 运行shell脚本
    [root@localhost opt]# ./shell.sh

root用户计划任务

  1. 打开文件
    crontab -e
  2. 添加任务
    #分时日月周 命令 脚本 #* * * * * /bin/bash /opt/shell2.sh
  3. 查看计划任务
    crontab -l -u root

shell编程

标签:chm   localhost   查看   local   inux   readonly   shell   pass   创建文件   

原文地址:https://www.cnblogs.com/pycrab/p/9420479.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!