linux?????????????????????????????????
-
- 1.??????????????????
- 2.at?????????????????????
- 3.??????????????????
- 3.1 crontab ??????????????????
- 3.2????????????crontab?????????
- 3.3crontab?????????(????????????????????????)
- 3.4??????????????????????????????(??????????????????????????????)
- 3.5crontab???????????????
- 4.????????????????????????????????????(?????????????????????????????????)
1.??????????????????
?????? dnf postfix mail ?????????????????????????????????
??????????????????????????????????????????????????????
POSTFIX
?????????????????????????????????postfix???Wietse Venema???IBM???GPL?????????????????????MTA?????????????????????????????????postfix???Wietse Venema???????????????????????????sendmail????????????????????????????????????Internet????????????????????????????????????????????????sendmail????????????????????????100???????????????sendmail????????????????????????????????????????????????????????????????????????Postfix?????????????????????????????????????????????????????????sendmail???????????????????????????
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsICM38FdsYkRGZkRG9lcvx2bjxiNx8VZ6l2csYXNXFGds1mYwVjMMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnLxkTN2MTMxEjMxADOwAjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
systemctl enable --now postfix
????????????
[[email??protected] libvirt]# at 18:26 ????????????????????????
warning: commands will be executed using /bin/sh
at> date #????????????
at> <EOT> #crtl+D ????????????
job 4 at Sat Aug 1 18:26:00 2020
You have mail in /var/spool/mail/root
????????????
[[email??protected] ~]# at now+1min ##??????1??????
at> rm -fr /mnt/*
at> <EOT>
at -l | ?????????????????? |
---|---|
at -c ????????? | ?????????????????? |
at -r ????????? | ?????????????????? |
?????? (????????? ????????????????????????????????????????????????????????????at??????????????????)
[[email??protected] libvirt]# mail root -s test messages ????????????
Subject: date ????????????
. ??????
EOT
Null message body; hope that's ok
[[email??protected] libvirt]# mail ??????????????????
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 2 messages 2 new
>N 1 root Sat Aug 1 18:24 19/699 "date"
N 2 Mail Delivery System Sat Aug 1 18:24 93/3156 "Undelivered M"
& Held 2 messages in /var/spool/mail/root ????????????????????????
[[email??protected] ~]# mail --help ??????????????????
mail: illegal option -- -
Usage: mail -eiIUdEFntBDNHRVv~ -T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE -f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users
mail -u root | ???????????????????????? |
---|---|
1 | ????????????????????? |
q | ?????? |
> /var/spool/mail/root | ???????????? |
[[email??protected]_nodel network-scripts]# mail root -s test messages
Subject: aaaaaa
.
EOT
Null message body; hope that's ok
[[email??protected]_nodel network-scripts]# mail -u root ##########????????????????????????
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/mail/root": 2 messages 2 new
>N 1 root Sat Aug 1 13:40 19/709 "aaaaaa"
N 2 Mail Delivery System Sat Aug 1 13:40 93/3179 "Undelivered Mail Returned to Sender"
& 1 #############??????????????????1?????????
Message 1:
From [email??protected]_nodel.westos.com Sat Aug 1 13:40:05 2020
Return-Path: <[email??protected]_nodel.westos.com>
X-Original-To: root
Delivered-To: [email??protected]_nodel.westos.com
Date: Sat, 01 Aug 2020 13:40:05 +0800
To: [email??protected]_nodel.westos.com, [email??protected]_nodel.westos.com,
-[email??protected]_nodel.westos.com, [email??protected]_nodel.westos.com
Subject: aaaaaa
User-Agent: Heirloom mailx 12.5 7/5/10
Content-Type: text/plain; charset=us-ascii
From: root <[email??protected]_nodel.westos.com>
Status: R
& headers ############### ?????????????????????
> 1 root Sat Aug 1 13:40 19/709 "aaaaaa"
N 2 Mail Delivery System Sat Aug 1 13:40 93/3179 "Undelivered Mail Returned to Sender"
& q ###################??????
Held 2 messages in /var/mail/root
2.at?????????????????????
/etc/at.deny | ??????????????????????????????????????????????????????????????????at |
---|---|
/etc/at.allow | ?????????????????????????????????????????????????????????????????????at,??????????????????????????????????????????/etc/at.deny?????? |
??????????????????????????????????????????????????????????????????at???
?????????
[[email??protected] ~]# cat /etc/at.deny
lee ????????????lee????????????
[[email??protected] ~]$ at 12:22 ?????????????????????????????????at??????
You do not have permission to use at.
?????????
[[email??protected] ~]# touch /etc/at.allow ?????????????????? ?????????????????????????????????????????????????????????
[[email??protected] ~]$ at 12:22
You do not have permission to use at.
[[email??protected] ~]# su - lee
[[email??protected] ~]$ at 12:22 ??????????????????????????????????????????
You do not have permission to use at.
[[email??protected] ~]# cat /etc/at.allow ?????????????????????
westos
[[email??protected] ~]# su - lee
[[email??protected] ~]$ at 12:22 ??????????????????????????????????????????at
You do not have permission to use at.
[[email??protected] ~]$ su - westos
Password:
[[email??protected] ~]$ at 12:22 ?????????????????????????????????at??????
warning: commands will be executed using /bin/sh
at> date
at> <EOT>
job 7 at Sun Aug 2 12:22:00 2020
[[email??protected] ~]$
3.??????????????????
3.1 crontab ??????????????????
[[email??protected]_nodel cron]# cd /etc/cron.d/
[[email??protected]_nodel cron.d]# ls
0hourly raid-check
[[email??protected]_nodel cron.d]# cat 0hourly ###??????????????????
# Run the hourly jobs
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
01 * * * * root run-parts /etc/cron.hourly
* 1 2 3 4 | ?????? ?????? ?????? ????????? /???????????? ???????????? |
---|---|
* * * * * | ????????? |
*/2 * * * * | ???????????? |
*/2 09-17 * * * | ##???7-???5???????????? |
*/2 */2 * * * | ??????2?????????????????? |
*/2 09-17 3,5 1 5 | ????????????3??????5????????????????????????9??????17??? ??????fenzhong |
*/2 09-17 * * 5 | ???????????????9???5???????????? |
3.2????????????crontab?????????
crond.service ##???????????????????????????????????? (??????????????????)
3.3crontab?????????(????????????????????????)
crontab -e -u
-e????????? -u user ??????????????????
* * * * * ??????
crontab -l -u
??????????????????
crontab -r -u
??????????????????
????????????????????????
-u user??????????????????????????????crontab?????????????????????-u ixdba???????????????ixdba?????????crontab???????????????????????????root??????????????????
file???file????????????????????????,?????????file??????crontab??????????????????????????????crontab???????????????????????????????????????????????????crontab??????????????????????????????????????????????????????????????????????????????crontab???
-e????????????????????????crontab?????????????????????????????????????????????????????????????????????crontab?????????
-l????????????????????????crontab?????????????????????????????????????????????????????????????????????crontab???????????????
-r??????/var/spool/cron??????????????????????????????crontab???????????????????????????????????????????????????????????????crontab?????????
-i?????????????????????crontab???????????????????????????
3.4??????????????????????????????(??????????????????????????????)
vim /etc/cron.d/file
* * * * * username action
* * * * * root rm -fr /mnt/*
?????????????????????(??????????????????)
3.5crontab???????????????
/etc/cron.deny ##??????????????????????????????????????????????????????????????????crontab
/etc/cron.allow ##?????????????????????????????????????????????????????????????????????crontab ##??????????????????????????????????????????/etc/at.deny??????
##??????????????????????????????/etc/cron.d/???????????????????????????????????????
chmod 777 /mnt/ ????????????????????????????????????????????????????????????
[[email??protected] ~]# rm -fr /mnt/*
[[email??protected] ~]# watch -n 1 ls -lR /mnt/
[[email??protected] ~]# cat /etc/cron.deny
lee
[[email??protected] cron.d]# cat /etc/cron.d/westos
* * * * * lee touch /mnt/file{1..5}
?????????????????? lee?????????????????? ??????at????????????????????????
/mnt/:
total 0
-rw-r--r-- 1 lee lee 0 Aug 1 20:01 file1
-rw-r--r-- 1 lee lee 0 Aug 1 20:01 file2
-rw-r--r-- 1 lee lee 0 Aug 1 20:01 file3
-rw-r--r-- 1 lee lee 0 Aug 1 20:01 file4
-rw-r--r-- 1 lee lee 0 Aug 1 20:01 file5
4.????????????????????????????????????(?????????????????????????????????)
??????????????????????????????????????????????????????????????????/usr/lib/tmpfiles.d/xxxx.conf ???????????? d /mnt/westos 1777 root root 8s????????????????????????????????????/mnt/westos?????????????????????????????????????????? systemd-tmpfiles --clean /lib/tmpfiles.d/westos.conf ????????????????????????????????? ???8s????????????
???????????????????????? ?????????????????????????????????
/usr/lib/tmpfiles.d/xxxx.conf
??????????????????????????????????????????
vim /usr/lib/tmpfiles.d/westos.conf
?????? ?????? ?????? ?????? ????????? ???????????????????????????
d /mnt/westos 1777 root root 8s
systemd-tmpfiles --creat /lib/tmpfiles.d/westos.conf
systemd-tmpfiles --clean /lib/tmpfiles.d/westos.conf
??????????????????????????????????????????