Debian / Ubuntu 自动检查安装更新

Kevin 教程 3,580 次浏览 57条评论

服务器环境与常用的桌面版系统不同,很多人在部署好服务后就很少登录机器,除非有良好习惯才会经常上去检查更新。要想省心解决这个问题,可以设置系统自动检查安装更新。具体方法步骤如下。

激活自动更新程序

部分系统版本自带有unattended-upgrades软件包。如果没有,手动安装下。

# 检查系统是否已安装(没有安装则无信息返回)
dpkg -l | grep unattended-upgrades
# 从包管理器获取安装
apt-get update && apt-get install unattended-upgrades

安装后运行dpkg-reconfigure -plow unattended-upgrades命令启动服务配置向导。

 ┌────────────┤ Configuring unattended-upgrades ├─────────────┐
 │                                                            │
 │ Applying updates on a frequent basis is an important part  │
 │ of keeping systems secure. By default, updates need to be  │
 │ applied manually using package management tools.           │
 │ Alternatively, you can choose to have this system          │
 │ automatically download and install important updates.      │
 │                                                            │
 │ Automatically download and install stable updates?         │
 │                                                            │
 │               <Yes>               <No>                     │
 │                                                            │
 └────────────────────────────────────────────────────────────┘

选择YES确认开启,如果提示选择更新模式,直接回车使用默认值即可。之后程序会自动生成/etc/apt/apt.conf.d/20auto-upgrades配置文件激活服务。

通过编辑该配置文件,可以按需设置自动更新运行方式,并添加其他操作。下面为示例配置。

// 每天刷新软件包列表
APT::Periodic::Update-Package-Lists "1";
// 每天下载可用更新文件
APT::Periodic::Download-Upgradeable-Packages "1";
// 每7天运行升级软件包
APT::Periodic::Unattended-Upgrade "7";
// 每21天清除包缓存文件
APT::Periodic::AutocleanInterval "21";

更多功能参数请查看/etc/cron.daily/apt文件描述。

配置自动更新选项

如果需要调整更新策略,例如添加或排除软件包更新。在/etc/apt/apt.conf.d/50unattended-upgrades文件内设置,里面有详细配置说明。

Unattended-Upgrade::Origins-Pattern选项控制自动更新软件包类型,默认只升级系统安全类更新,适合大部分情况下使用。

// Debian 默认值
"origin=Debian,codename=${distro_codename},label=Debian-Security";
// Ubuntu 默认值
"origin=Ubuntu,archive=${distro_codename}-security";

为了掌握自动更新情况,可以添加邮箱地址以接收更新报告。别忘了取消注释使其生效。

Unattended-Upgrade::Mail "user@example.com";

安装配置邮件服务

要使上面设置的邮件通知功能生效,需要安装和配置mailx服务,详细流程请参考这篇文章

配置好邮件服务后,使用下面命令测试邮件是否可以正常发送。

echo "This is a test mailing" | mail -s "Test mail" user@example.com

测试自动更新服务

完成上面设置后,运行更新命令测试更新服务是否正常。

unattended-upgrade -v -d

如无意外,更新后会收到详细报告邮件。包括更新了哪些软件包,是否要重启服务器等信息。

更新通知邮件

到处,无人值守自动更新服务就设置完成了,以后不用再惦记检查更新这档事啦。

评论列表

  1. #1

    Hi, very nice website, cheers!
    ——————————————————
    Need cheap and reliable hosting? Our shared plans start at $10 for an year and VPS plans for $6/Mo.
    ——————————————————
    Check here: https://www.reliable-webhosting.com/

  2. #2

    penile injections vs dapoxetine https://salemeds24.wixsite.com/dapoxetine

  3. #3

    generic hydroxychloroquine https://hhydroxychloroquine.com/

  4. #4

    hydroxychloroquine long term https://hydroxychloroquine.webbfenix.com/

  5. #5

    will ivermectin kill corona https://ivermectin.mlsmalta.com/

  6. #6

    priligy uk price https://dapoxetine.confrancisyalgomas.com/

  7. #7

    brand cialis online pharmacy https://wisig.org/

  8. #8

    vidalista warnings https://vidalista40mg.mlsmalta.com/

  9. #9

    albuterol interactions with other drugs https://amstyles.com/

  10. #10

    plaquenil for chronic fatigue syndrome https://hydroxychloroquinee.com/

  11. #11

    women’s cialis testimonials https://tadalafili.com/

  12. #12

    price priligy usa https://ddapoxetine.com/

  13. #13

    buy cialis https://atadalafil.online/

  14. #14

    buy cialis https://tadalafileo.online/

  15. #15

    hydroxychloroquine for covid 19 dosage https://hydroxychloroquine.lm360.us/

  16. #16

    zoloft and tamoxifen interaction https://tamoxifen.mrdgeography.com/

  17. #17

    vidalista 40 mg daily https://vidalista.mlsmalta.com/

  18. #18

    time curve for cefixime effectiveness https://ceefexime.co/

  19. #19

    I am glad that I discovered this website, precisely the right info that I was searching for! https://local-auto-locksmith.co.uk/kia/

  20. #20

    I enjoy you because of all of the effort on this blog. Betty delights in carrying out internet research and it’s easy to see why. A lot of people hear all about the compelling form you convey both interesting and useful guidelines by means of the blog and attract contribution from other individuals about this area of interest and my child has always been becoming educated a great deal. Enjoy the remaining portion of the new year. You’re carrying out a dazzling job. https://lvagroupinc.com/

  21. #21

    I’m just commenting to let you be aware of of the fabulous discovery my cousin’s daughter experienced going through your site. She even learned lots of issues, most notably how it is like to have a very effective giving mindset to have many others just gain knowledge of chosen grueling matters. You really did more than our desires. Many thanks for distributing the important, healthy, educational and as well as easy thoughts on the topic to Gloria. https://luvoxfluvoxamine.com/

  22. #22

    I precisely had to say thanks all over again. I’m not certain the things I could possibly have created in the absence of the actual hints discussed by you concerning such concern. It actually was a real difficult condition for me personally, but discovering a new professional fashion you handled it forced me to cry for delight. I’m grateful for the assistance and as well , have high hopes you comprehend what a powerful job you’re carrying out educating men and women by way of your blog. I am certain you’ve never come across all of us. https://sinequandoxepin.com/#

  23. #23

    100 mg cialis cialis https://tadalafil.cleckleyfloors.com/

  24. #24

    how to get prescriptions without a doctor https://medpills.bee-rich.com/

  25. #25

    how to get prescriptions without a doctor https://buymeds.mlsmalta.com/

  26. #26

    medication without a doctor prescription https://edmeds.buszcentrum.com/

  27. #27

    acticin tablet

  28. #28

    buy cialis black online

  29. #29

    same day loans bad credit

  30. #30

    loan no credit check

  31. #31

    tadalafil prescription cost uk https://cialis.adicbc.com/

  32. #32

    tadalafil prescription cost uk https://cialis.studiowestinc.com/

  33. #33

    ciprofloxacin cost uk

  34. #34

    guaranteed payday loans no teletrack

  35. #35

    cialis website https://cialzi.com/

  36. #36

    does azithromycin have long term side effects http://aziithromycin.com/

  37. #37

    order hydroxychloroquine from india http://hydroxychloroquined.online/

  38. #38

    can tadalafil cause weight gain https://cialis.cleckleyfloors.com/

  39. #39

    can tadalafil cause weight gain https://cialis360.jueriy.com/

  40. #40

    Every weekend i used to visit this website, as i wish for enjoyment, since this this site conations really nice funny stuff too. https://cialis.bee-rich.com/tadalafil

  41. #41

    generic vidalista online canadian pharmacy http://vidallista.com/

  42. #42

    It is the best time to make some plans for the future and
    it’s time to be happy. I’ve learn this post and if I may
    I wish to counsel you few attention-grabbing issues or suggestions.
    Perhaps you could write next articles referring to this article.
    I want to read more issues about it! https://hydroxychloroquineb.bee-rich.com/

  43. #43

    I really like your writing style, good information, thanks for putting up :D. “The superfluous is very necessary.” by Francois Marie Arouet Voltaire.

    http://www.vreyrolinomit.com/

  44. #44

    I do trust all the concepts you have presented on your post.
    They are very convincing and can definitely work.
    Nonetheless, the posts are very short for beginners. Could you please prolong them a little from subsequent
    time? Thanks for the post. http://www.deinformedvoters.org/dapoxetine-60mg

  45. #45

    Attractive component to content. I just stumbled upon your weblog and in accession capital to
    claim that I get actually enjoyed account your weblog posts.
    Anyway I’ll be subscribing for your augment and even I fulfillment you get admission to persistently rapidly. http://www.deinformedvoters.org/sildenafil-price

  46. #46

    Dzięki za zaleceń dotyczących naprawy kredytu na temat tego niesamowitego witryny. Kilka rzeczy i chciałbym powiedzieć ludziom zawsze zrezygnować z konkretnej mentalności mogą dzisiaj i wypłać później. Like a as be a} społeczeństwo {my|my wszyscy|my wszyscy|wielu z nas|większość z nas|większość ludzi} ma tendencję do {robienia tego|robienia tamtego|próbowania tego|zdarzyć się|powtórz to} dla wielu {rzeczy|problemów|czynników}. Obejmuje to {wakacje|wakacje|wypady|wyjazdy wakacyjne|wycieczki|rodzinne wakacje}, meble, {i|jak również|a także|wraz z|oprócz|plus} przedmiotów {chcemy|chcielibyśmy|życzymy|chcielibyśmy|naprawdę chcielibyśmy to mieć}. Jednak {musisz|musisz|powinieneś|powinieneś chcieć|wskazane jest, aby|musisz} oddzielić {swoje|swoje|to|twoje obecne|swoje|osoby} chcą {od wszystkich|z potrzeb|z}. {Kiedy jesteś|Kiedy jesteś|Kiedy jesteś|Jeśli jesteś|Tak długo, jak jesteś|Kiedy} pracujesz, aby {poprawić swój kredyt|poprawić swoją zdolność kredytową|zwiększyć swój kredyt|zwiększyć swój kredyt|podnieś swój ranking kredytowy|popraw swój kredyt} wynik {musisz zrobić|zrobić|faktycznie potrzebujesz|naprawdę musisz} dokonać kilku {poświęceń|kompromisów}. Na przykład {możesz|możesz|możesz|możesz|będziesz mógł|| możesz|prawdopodobnie możesz} robić zakupy online {aby zaoszczędzić pieniądze|aby zaoszczędzić pieniądze|aby zaoszczędzić} lub {możesz przejść do|może się zwrócić|może odwiedzić|może obejrzeć|może sprawdzić|może kliknąć} używane {sklepy|sklepy|detaliści|sprzedawcy|punkty sprzedaży|dostawcy} zamiast {drogie|drogie|drogie|drogie|drogie|drogich} domów towarowych {dla|w odniesieniu do|dotyczących|odnoszących się do|przeznaczonych dla|do zdobycia} odzieży {strzykawki insulinowe 1ml|strzykawki tuberkulinowe|strzykawki|strzykawka|strzykawki insulinowe|strzykawki do insuliny|strzykawki trzyczęściowe tuberkulinowe|strzykawka tuberkulinowa|strzykawka insulinowa|strzykawka do insuliny|strzykawka trzyczęściowe tuberkulinowa}. https://strzykawkin.pl/

  47. #47

    cialis from canada online pharmacy http://edonline.online/

  48. #48

    buy hydroxychloroquine online https://hydroxychloroquinex.com/

  49. #49

    Magnificent beat ! I would like to apprentice whilst you amend your web site, how could i subscribe for a weblog web site? The account aided me a applicable deal. I have been a little bit familiar of this your broadcast provided vibrant transparent concept

    https://www.youtube.com/watch?v=tm_FEaULxf8

  50. #50

    Wow, superb blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your website is great, as well as the content!

    http://www.vreyrolinomit.com/

  51. #51

    benefits of daily vidalista use http://viidalista.co/

  52. #52

    Your method of explaining everything in this paragraph is truly
    good, every one can without difficulty be aware of
    it, Thanks a lot. https://cialis.grassfed.us/tadalafil

  53. #53

    naturally like your website but you need to take a look at
    the spelling on several of your posts. A number of them are rife with spelling issues
    and I to find it very bothersome to tell the reality on the other hand I’ll surely come back again. http://www.deinformedvoters.org/cialis-usa

  54. #54

    Have you ever heard of second life (sl for short). It is basically a online game where you can do anything you want. sl is literally my second life (pun intended lol). If you would like to see more you can see these Second Life articles and blogs

    wiki.jokaydia.com/index.php?title=LiteratureCompositionCreative_Writing&direction=next&oldid=438

  55. #55

    Have you ever heard of second life (sl for short). It is essentially a online game where you can do anything you want. SL is literally my second life (pun intended lol). If you want to see more you can see these sl articles and blogs

    redurl.info/http/angelaathomas.com

  56. #56

    It’s going to be ending of mine day, except before end I
    am reading this great paragraph to improve my
    knowledge. https://hydroxychloroquinec.cleckleyfloors.com/

  57. #57

    liquid prednisone brands https://bvsinfotech.com/

发表评论

电邮地址用于 Gravatar 头像显示,不会被公开可见。