wget 安装java wget编译安装_nginx

Linux 编译安装、压缩打包、定时任务详细解释~

目录

  • Linux 编译安装
  • 知识储备:
  • wget命令
  • 编译安装
  • Linux 压缩打包
  • gzip压缩
  • bzip2压缩
  • tar打包
  • Linux 定时任务
  • 相关文件及操作


wget 安装java wget编译安装_nginx_02


Linux 编译安装

编译安装就是使用源代码安装,编译打包软件

知识储备:

wget命令

  • 简介:

wget命令用来从指定的URL下载文件。wget非常稳定,它在带宽很窄的情况下和不稳定网络中有很强的适应性,如果是由于网络的原因下载失败,wget会不断的尝试,直到整个文件下载完毕。如果是服务器打断下载过程,它会再次联到服务器上从停止的地方继续下载。这对从那些限定了链接时间的服务器上下载大文件非常有用。

  • 格式:
    wget [选项] [参数] ------ (用哪个参数man一下就可以了)

编译安装

  1. 编译安装的特点
  • 可以自定制软件
  • 按需构建软件
  1. 编译安装的步骤
    👉[nginx官网](nginx: download)

以nginx为例

# 1、下载源代码包
wget https://nginx.org/download/nginx-1.20.2.tar.gz

# 2、解压
tar -xf nginx-1.20.2.tar.gz

# 3、设置系统参数
cd nginx-1.20.2
# 4、自定制404界面
vim ./src/core/nginx.h # 修改的内容如下图
# 4.1、设置系统参数
./configure 

# 5、编译
make
# 6、安装
make install

# 安装好后,目录/usr/local下就会多了nginx目录
# 7、启动
/usr/local/nginx/sbin/nginx
# 7.1、关闭服务
/usr/local/nginx/sbin/nginx -s stop
systemctl stop nginx

wget 安装java wget编译安装_nginx_03

wget 安装java wget编译安装_编译安装_04


Linux 压缩打包

gzip压缩

  • 命令:
  • 压缩:gzip [压缩文件]
  • 解压:gzip -d [解压文件]
# a.txt 是我提前建好的
  # 压缩
  [root@localhost test]# gzip a.txt 
  [root@localhost test]# ls
  a.txt.gz
  # 解压
  [root@localhost test]# gzip -d a.txt.gz 
  [root@localhost test]# ls
  a.txt

bzip2压缩

  • 命令:
  • 压缩:bzip2 [压缩文件]
  • 解压:bzip2 -d [压缩包]
# 压缩
[root@localhost test]# bzip2 a.txt 
[root@localhost test]# ls
a.txt.bz2
# 解压
[root@localhost test]# bzip2 -d a.txt.bz2 
[root@localhost test]# ls
a.txt

由于gzipbzip2无法压缩目录,使用tar命令

# 无法压缩命令
[root@localhost ~]# gzip test
gzip: test is a directory -- ignored

tar打包

  • 命令
  • tar [参数] [打包文件]
  • 参数:
  • -f : 指定打包的包名称
  • -c : 打包
  • -v : 显示打包的过程
  • -z : 使用gzip压缩压缩包
  • -j : 使用bzip2压缩压缩包
  • -x : 解压(解压不需要指定压缩类型)
  • -t : 查看压缩包内部的内容
  • -P :忽略使用绝对路径时报出的错误

注意:

  1. 压缩时是什么路径,解压缩时就是什么路径,所以为了安全不要使用绝对路径压缩。
  2. -f参数后面永远跟压缩包名称(-f放最后)
# -fc参数的使用,指定打包的包名称,并打包
[root@localhost ~]# tar -cf test.tar test
[root@localhost ~]# ll
-rw-r--r--  1 root root 10240 Dec 17 19:26 test.tar
# 使用gzip压缩
[root@localhost ~]# gzip test.tar 
[root@localhost ~]# ll
-rw-r--r--  1 root root  211 Dec 17 19:26 test.tar.gz


# 使用参数直接打包压缩
[root@localhost ~]# tar -czf test.tar.gz test
[root@localhost ~]# ll
-rw-r--r--  1 root root  202 Dec 17 19:40 test.tar.gz

# 解压
[root@localhost ~]# tar -xf test.tar.gz

Linux 定时任务

定时任务类似生活中使用的闹钟,可以自动完成操作命令,定时备份系统数据信息等功能

相关文件及操作

目录下写可执行文件(x.sh),就会自动执行

  • 系统定时任务周期:每小时
  • 控制定时任务目录:/etc/cron.hourly
[root@localhost cron.hourly]# cd /etc/cron.hourly/
[root@localhost cron.hourly]# ll
total 4
-rwxr-xr-x. 1 root root 392 Aug  9  2019 0anacron
  • 系统定时任务周期:每一天
  • 控制定时任务目录:/etc/cron.daily
[root@localhost cron.hourly]# cd /etc/cron.daily/
[root@localhost cron.daily]# ll
total 8
-rwx------. 1 root root 219 Apr  1  2020 logrotate
-rwxr-xr-x. 1 root root 618 Oct 30  2018 man-db.cron
  • 系统定时任务周期:每一周
  • 控制定时任务目录:/etc/cron.weekly
[root@localhost cron.monthly]# cd /etc/cron.weekly/
  • 系统定时任务周期:每个月
  • 控制定时任务目录:/etc/cron.monthly
[root@localhost cron.daily]# cd /etc/cron.monthly/
  • 系统定时任务的配置文件之一 : /etc/crontab

wget 安装java wget编译安装_nginx_05

  • 实际操作:
  • 添加定时任务:crontab -e
  • 查看定时任务:crontab -l
# *  *  *  *  *  : crontab表达式
# 案例:每天的凌晨2:50执行/root/1.sh
# 在1.sh中添加执行语句
# 添加任务
[root@localhost etc]# crontab -e   
# 查看定时任务
[root@localhost etc]# crontab -l
#Timing synchronization time
0 */1 * * * /usr/sbin/ntpdate ntp1.aliyun.com &>/dev/null

wget 安装java wget编译安装_定时任务_06


  • 定时任务配置文件 : /var/spool/cron/root

每一个用户的定时任务是相对隔离,在/var/spool/cron目录下,以当前用户的用户名命名的文件。

  • 定时任务格式
# * 代表每的意思
基础格式 : * * * * *
每隔2分钟执行
	*/2 * * * *
		
每天的2,4,6,8,10这4个小时的1分钟执行
	01 2,4,6,10 * * * 
		
每天的2到6点执行
	00 2-6 * * *
	
每天的2到6点中每隔2小时执行
	00 2-6/2 * * *
		
00 02 * * 02   : 每天的2点时执行,但是这天必须时周二
  • 定时任务服务运行记录日志文件 : /var/log/cron
  • 查看日志命令:
  • head/tail
  • -n : 查看指定多少行
  • tail/tail -f
  • -f : 监控文件变化
  • less
  • 定时任务服务禁止用户运行名单 : /etc/cron.deny(定时任务黑名单)

wget 安装java wget编译安装_nginx_07