内容一:continue
continue 的作用是在 for、while 等循环中,跳过这次操作直接进入下一个循环
内容二:return
return 的作用是退出函数
内容三:exit
exit 的作用是当此脚本正在运行时退出此脚本
continue 的作用是在 for、while 等循环中,跳过这次操作直接进入下一个循环
return 的作用是退出函数
exit 的作用是当此脚本正在运行时退出此脚本
# dirname -- "$( readlink -f -- "$0"; )";
# dnf install at
# systemctl enable --now atd
# at now +3 minutes
warning: commands will be executed using /bin/sh
(
补充:这里的 now +3 minutes 代表当前时间 3 分钟后执行。
所有可选的时间选项如下:
1) now +3 minutes,3 分钟后执行
2) now +3 hours,3 小时后执行
3) now +3 days,3 天后执行
4) 15:30,当天 15:30 时执行
5) 15:30 2025-01-01,2025 年 1 月 1 日时执行
6) teatime,当天 16:00 执行
7) midnight 次日凌晨 00:00 执行
)
at> reboot
(补充:这里以执行 reboot 命令为例)
at> <CtrlD> + <D>
at> <EOT>
job 5 at Tue Sep 16 22:37:00 2025
#
# at -l
6 Tue Sep 16 22:37:00 2025 a root
或者:
# atq
6 Tue Sep 16 22:37:00 2025 a root
# at -c 6
(补充:这里以显示第 6 条 at 命令为例,这里的 6 是步骤 4.1 的输出结果)
# vim test.sh
创建以下内容:
#!/bin/bash
at now + 1min << EOF
reboot
EOF
(补充:这里以创建名为 test.sh 在 1 分钟后重启系统为例)
# stat <file>
# stat <option> <parameter> <file>
1) -c 或者 –format=FORMAT,只显示文件的时间
2) –printf=FORMAT,只显示文件的时间同时不换行打印
1) %a, access rights in octal (note ‘#’ and ‘0’ printf flags)
2) %A, access rights in human readable form
3) %b, number of blocks allocated (see %B)
4) %B, the size in bytes of each block reported by %b
5) %C, SELinux security context string
6) %d, device number in decimal
7) %D, device number in hex
8) %f, raw mode in hex
9) %F, file type
10) %g, group ID of owner
11) %G, group name of owner
12) %h, number of hard links
13) %i, inode number
14) %m, mount point
15) %n, file name
16) %N, quoted file name with dereference if symbolic link
17) %o, optimal I/O transfer size hint
18) %s, total size, in bytes
19) %t, major device type in hex, for character/block device special files
20) %T, minor device type in hex, for character/block device special files
21) %u, user ID of owner
22) %U, user name of owner
23) %w, time of file birth, human-readable; – if unknown
24) %W, time of file birth, seconds since Epoch; 0 if unknown
25) %x, time of last access, human-readable
26) %X, time of last access, seconds since Epoch
27) %y, time of last data modification, human-readable
28) %Y, time of last data modification, seconds since Epoch
29) %z, time of last status change, human-readable
30) %Z, time of last status change, seconds since Epoch
[mingyuzhu@liux ~]$ stat -c %y test.txt
2025-03-31 17:26:11.399060089 +0800
或者:
[mingyuzhu@liux ~]$ stat --format=%y test.txt
2025-03-31 17:26:11.399060089 +0800
(补充:这里以显示 test.txt 文件的时间为例)
[mingyuzhu@liux ~]$ stat --printf=%y test.txt
2025-03-31 17:26:11.399060089 +0800[mingyuzhu@liux ~]$
(补充:这里以显示 test.txt 文件的时间为例)
# stat -c "%a %u %g" /boot/grub2/grub.cfg
600 0 0
(
补充:
1) 这里以显示 /boot/grub2/grub.cfg 文件的权限、所属主和所属组为例
2) 从输出结果可以看出此文件的权限代码是 600、所属主代码是 0、所属组代码是 0
)
# stat -c 'User=%U Group=%G Permissions=%a' /etc/passwd
User=root Group=root Permissions=644
(
补充:
1) 这里以显示 /boot/grub2/grub.cfg 文件的权限、所属主和所属组为例
2) 从输出结果可以看出此文件的所属主是 root、所属组是 root、权限代码是 644
3) 这里所属主的前缀是 User=、所属组的前缀是 Group=、权限代码的前缀是 Permissions=
)
$ cat << EOF
> echo "this is EOF test"
> echo "this is line 2"
> EOF
echo "this is EOF test"
echo "this is line 2"
(
补充:这里以输出以下内容为例:
echo “this is EOF test”
echo “this is line 2”
)