Ubuntu安装git

1、检查git是否已经安装,输入git version命令即可,如果没有显示版本号表示没有安装git

2、安装git

sudo apt-get install git

3、配置git全局环境
  git config --global user.name “用户名”
  git config --global user.email “邮箱地址”

4、生成ssh密钥
  ssh-keygen -C ‘you email address@gmail.com’ -t rsa
  会在用户目录~/.ssh/下建立相应的密钥文件。
  在这里插入图片描述
5、创建完公钥后,需要上传。
  使用命令cd /.ssh进入/.ssh文件夹或者进入cd /root/.ssh,输入
  cat id_rsa.pub
  打开id_rsa.pub文件,复制其中所有内容。
  在这里插入图片描述
 接着访问github网页,新建SSH公钥,标题栏名称自定义,公钥栏把刚才复制的内容粘贴进去。
 在这里插入图片描述
6.克隆项目到本地

git clone “github 项目地址”
  切换分支:
  git checkout

crontab定时任务

1、安装cron工具:

root@ubuntu-14:~# apt-getinstall cron

2、开启定时任务:crontab –e

定时任务语句格式为:执行周期+命令。

周期有5个域,分别是分钟,小时,日(day of month),月(month of year),周几(day of week)。每个域不加限制任意的话用*,整体格式为:

          • user command

分 时 日 月 周 用户 命令

我的脚本是 /root/1.py

执行环境为 /usr/bin/python3.5

每两分钟运行一次

则语句为:

*/2 * * * * /usr/bin/python3.5/root/1.py &>> /root/auto.log
在这里插入图片描述
3、写完后重启cron 服务

root@ubuntu-14:~# servicecron start

4、其他命令:

重启cron 服务:

service cron restart

检查cron服务的状态:

root@ubuntu-14:~# servicecron status
service cron start //启动服务

service cron stop //关闭服务

service cron restart //重启服务

service cron reload //重新载入配置

service cron status //查看crontab服务状态
6、常用的周期格式

每五分钟执行 */5 * * * *

每小时执行 0 * * * *

每天执行 0 0 * * *

每周执行 0 0 * * 0

每月执行 0 0 1 * *

每年执行 0 0 1 1 *

每分钟执行一次 * * * * * user command

每隔2小时执行一次**/2 ** * user command (/表示频率)

每天8:30分执行一次308 * * * user command

每小时的30和50分各执行一次 30,50 * * * * user command(,表示并列)

每个月的3号到6号的8:30执行一次 30 8 3-6 * * user command (-表示范围)

每个星期一的 8:30 执行一次 30 8 * * 1 user command (周的范围为0-7,0和7代表周日)

个人记录sh脚本写入使用Shell脚本查找程序对应的进程ID,并杀死进程:

#!/bin/sh
NAME='shell.php'
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
echo $ID
echo "---------------"
for id in $ID
do
kill -9 $id
echo "killed $id"
done
echo "---------------"

1),将之保存为killprocess.sh
2),调用./killprocess.sh programmename。其中programme可以为程序名字,也可以是启动程序时的命令行,只要能在ps -ef | grep programmename 之后出现所有的该程序对应的进程即可

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐