{"id":315,"date":"2015-06-12T17:27:45","date_gmt":"2015-06-12T15:27:45","guid":{"rendered":"http:\/\/monodes.com\/predaelli\/?p=315"},"modified":"2015-06-12T17:27:45","modified_gmt":"2015-06-12T15:27:45","slug":"how-to-make-your-linux-pc-wake-from-sleep-automatically","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2015\/06\/12\/how-to-make-your-linux-pc-wake-from-sleep-automatically\/","title":{"rendered":"How to Make Your Linux PC Wake From Sleep Automatically"},"content":{"rendered":"<p>From <em><a href=\"http:\/\/linuxquestionhelp.blogspot.com\/2013\/04\/how-to-make-your-linux-pc-wake-from.html\">How to Make Your Linux PC Wake From Sleep Automatically<\/a><\/em><\/p>\n<p><a href=\"http:\/\/linuxquestionhelp.blogspot.it\/2013\/04\/how-to-make-your-linux-pc-wake-from.html\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-full\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2015\/06\/image172.png?w=910\" alt=\"\" \/><\/a><\/p>\n<p>I use<\/p>\n<blockquote><p>sudo rtcwake -m\u00a0mem -l -t $(date +%s -d \u2018tomorrow 06:30\u2019)<\/p><\/blockquote>\n<p>or<\/p>\n<blockquote><p>sudo \/usr\/sbin\/rtcwake -m mem -s $(( 8 * 3600))<\/p><\/blockquote>\n<p><!--more--><\/p>\n<blockquote><p>Want to put your Linux PC into sleep or hibernate mode and have it automatically wake at a specific time? You can easily do this with the rtcwake command, included by default with most Linux systems.<br \/>\nThis can be useful if you want your computer to do something at a specific time, but don\u2019t want it running 24\/7. For example, you could put your computer to sleep at night and have it wake up before you do to perform some downloads.<\/p>\n<h3>Using rtcwake<\/h3>\n<p>The <strong>rtcwake<\/strong> command requires root permissions, so it must be run with <strong>sudo<\/strong> on Ubuntu and other Ubuntu-derived distributions. On Linux distributions that don\u2019t use sudo, you\u2019ll have to log in as root with the <strong>su<\/strong> command first.<br \/>\nHere\u2019s the basic syntax of the command:<\/p>\n<blockquote><p>sudo rtcwake -m [type of suspend] -s [number of seconds]<\/p><\/blockquote>\n<p>For example, the following command suspends your system to disk (hibernates it) and wakes it up 60 seconds later:<\/p>\n<blockquote><p>sudo rtcwake -m disk -s 60<\/p><\/blockquote>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"lazyLoad\" title=\"image\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2015\/06\/image101.png?resize=650%2C212\" alt=\"\" width=\"650\" height=\"212\" border=\"\" \/><\/p>\n<h3>Types of Suspend<\/h3>\n<p>The<strong> -m<\/strong> switch accepts the following types of suspend:<\/p>\n<ul>\n<li><strong>standby<\/strong> \u2013 Standby offers little power savings, but restoring to a running system is very quick. This is the default mode if you omit the -m switch.<\/li>\n<li><strong>mem<\/strong> \u2013 Suspend to RAM. This offers significant power savings \u2013 everything is put into a low-power state, except your RAM. The contents of your memory are preserved.<\/li>\n<li><strong>disk<\/strong> \u2013 Suspend to disk. The contents of your memory are written to disk and your computer is powered off. The computer will turn on and its state will be restored when the timer completes.<\/li>\n<li><strong>off<\/strong> \u2013 Turn the computer off completely. rtcwake\u2019s man page notes that restoring from \u201coff\u201d isn\u2019t officially supported by the ACPI specification, but this works with many computers anyway.<\/li>\n<li><strong>no<\/strong> \u2013 Don\u2019t suspend the computer immediately, just set the wakeup time. For example, you could tell your computer to wake up at 6am. After that, can put it to sleep manually at 11pm or 1am \u2013 either way, it will wake up at 6am.<\/li>\n<\/ul>\n<h3>Seconds vs. Specific Time<\/h3>\n<p>The <strong>-s<\/strong> option takes a number of seconds in the future. For example, -s 60 wakes your computer up in 60 seconds, while -s 3600 wakes your computer up in an hour.<br \/>\nThe <strong>-t<\/strong> option allows you to wake your computer up at a specific time. This switch wants a number of seconds since the Unix epoch (00:00:00 UTC on January 1, 1970). To easily provide the correct number of seconds, combine the <strong>date<\/strong> command with the rtcwake command.<br \/>\nThe <strong>-l<\/strong> switch tells rtcwake that the hardware clock is set to local time, while the <strong>-u<\/strong> switch tells rtcwake that the hardware clock (in your computer\u2019s BIOS) is set to UTC time. Linux distributions often set your hardware clock to UTC time and translate that to your local time.<br \/>\nFor example, to have your computer wake up at 6:30am tomorrow but not suspend immediately (assuming your hardware clock is set to local time), run the following command:<\/p>\n<blockquote><p>sudo rtcwake -m no -l -t $(date +%s -d \u2018tomorrow 06:30\u2019)<\/p><\/blockquote>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"lazyLoad\" title=\"image\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2015\/06\/image102.png?resize=650%2C173\" alt=\"\" width=\"650\" height=\"173\" border=\"\" \/><\/p>\n<h3>More Tips<\/h3>\n<p>Use the &amp;&amp; operator to run a specific command after rtcwake wakes your system from sleep. For example, the following command suspends your computer to RAM, wakes it two minutes later, and then launches Firefox:<\/p>\n<blockquote><p>rtcwake -m mem -s 120 &amp;&amp; firefox<\/p><\/blockquote>\n<p>Integrate the rtcwake command into a cron script to automatically wake your computer at a specific time. The <strong>-m no<\/strong> switch can also be useful in a cron script. For example, you could run the<strong> rtcwake -m no -s 28800<\/strong> command in a cron script at 10pm every day. This would set your computer to wake up in 28800 seconds at 6:00am. However, your computer wouldn\u2019t go to sleep immediately \u2013 you could put it to sleep at 11pm or 1am and it would still wake at 6am normally.<\/p>\n<h3>Caveats<\/h3>\n<ul>\n<li>RTC stands for real-time clock. rtcwake uses your computer\u2019s hardware clock, which you can set in your BIOS, to determine when your computer will wake up. If you\u2019re using an old computer with a dying CMOS battery that can\u2019t keep the clock running properly, this won\u2019t work.<\/li>\n<li>If sleep, suspend to RAM, or hibernate don\u2019t work properly with your Linux system \u2013 perhaps because Linux doesn\u2019t have the drivers to make them work properly with your hardware \u2013 this may not work.<\/li>\n<li>Be careful when setting a laptop to automatically wake at a specific time. You wouldn\u2019t want it waking up, running, and overheating or running down its battery in a laptop bag.<\/li>\n<\/ul>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">From How to Make Your Linux PC Wake From Sleep Automatically I use sudo rtcwake -m\u00a0mem -l -t $(date +%s -d \u2018tomorrow 06:30\u2019) or sudo \/usr\/sbin\/rtcwake -m mem -s $(( 8 * 3600))<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2015\/06\/12\/how-to-make-your-linux-pc-wake-from-sleep-automatically\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[40,41],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-gnulinux","tag-sleep","tag-wake"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-55","jetpack-related-posts":[{"id":9912,"url":"https:\/\/monodes.com\/predaelli\/2022\/12\/14\/how-to-configure-wireless-wake-on-lan-for-linux-wifi-card\/","url_meta":{"origin":315,"position":0},"title":"How to configure wireless wake-on-lan for Linux WiFi card","author":"Paolo Redaelli","date":"2022-12-14","format":false,"excerpt":"How to configure wireless wake-on-lan for Linux WiFi card - nixCraft I have Network Attached Storage (NAS) server that backups all my devices. However, I am having a hard time with my Linux-powered laptop. I cannot back up my laptop\/computer when it is in suspended or sleep mode. How do\u2026","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2145,"url":"https:\/\/monodes.com\/predaelli\/2017\/02\/04\/life-plus-linux-look-before-you-paste-from-a-website-to-terminal\/","url_meta":{"origin":315,"position":1},"title":"Life plus Linux: Look before you paste from a website to terminal","author":"Paolo Redaelli","date":"2017-02-04","format":false,"excerpt":"All about making life easier and efficient with Linux Sorgente: Life plus Linux: Look before you paste from a website to terminal Look before you paste from a website to terminal Most of the time when we see a code snippet online to do something, we often blindly copy paste\u2026","rel":"","context":"In &quot;Senza categoria&quot;","block_context":{"text":"Senza categoria","link":"https:\/\/monodes.com\/predaelli\/category\/senza-categoria\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":11123,"url":"https:\/\/monodes.com\/predaelli\/2024\/01\/08\/prevent-sleep-suspend-when-not-logged-in\/","url_meta":{"origin":315,"position":2},"title":"Prevent sleep\/suspend when not logged in","author":"Paolo Redaelli","date":"2024-01-08","format":false,"excerpt":"Recently I've been logged into a laptop remotely a lot. Logging out from \"main\" session makes my Gnome on Debian 12 go to suspend after a while. To avoid it you just have to tell: sudo dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing' Thanks to WinEunuuchs2Unix for the answer I took\u2026","rel":"","context":"In &quot;Gnome&quot;","block_context":{"text":"Gnome","link":"https:\/\/monodes.com\/predaelli\/category\/gnome\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9107,"url":"https:\/\/monodes.com\/predaelli\/2022\/02\/16\/fai-fully-automatic-installation\/","url_meta":{"origin":315,"position":3},"title":"FAI &#8211; Fully Automatic Installation","author":"Paolo Redaelli","date":"2022-02-16","format":"link","excerpt":"FAI - Fully Automatic Installation FAI is a tool for unattended mass deployment of Linux. It's a system to install and configure Linux systems and software packages on computers as well as virtual machines, from small labs to large-scale infrastructures like clusters and virtual environments. You can take one or\u2026","rel":"","context":"In &quot;Debian&quot;","block_context":{"text":"Debian","link":"https:\/\/monodes.com\/predaelli\/category\/debian\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8844,"url":"https:\/\/monodes.com\/predaelli\/2021\/10\/18\/how-to-run-shell-script-as-systemd-service-in-linux\/","url_meta":{"origin":315,"position":4},"title":"How to Run Shell Script as Systemd Service in Linux ?","author":"Paolo Redaelli","date":"2021-10-18","format":false,"excerpt":"How to Run Shell Script as Systemd Service in Linux ? Here, we will make a manual script which will act like a process to find disk utilization of the Linux system. To begin, Make a bash script that redirects date and disk utilization in a file. You can create\u2026","rel":"","context":"In &quot;Tricks&quot;","block_context":{"text":"Tricks","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/tricks\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9307,"url":"https:\/\/monodes.com\/predaelli\/2022\/04\/27\/progressively-un-centoing\/","url_meta":{"origin":315,"position":5},"title":"Progressively un-centoing","author":"Paolo Redaelli","date":"2022-04-27","format":false,"excerpt":"I got slightly annoyed when Centos were terminated. In my efforts to Fedorize the server I use everyday to host the WordPress blog that records most of the work done on our Quality Managament System I encountered this annoying error Failed to download metadata for repo 'appstream': Cannot prepare internal\u2026","rel":"","context":"In &quot;Fedora - RedHat&quot;","block_context":{"text":"Fedora - RedHat","link":"https:\/\/monodes.com\/predaelli\/category\/fedora-redhat\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=315"}],"version-history":[{"count":0,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/315\/revisions"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}