systemd invalid argument - debugging delayed hibernation service file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm trying to implement the delayed hibernation unit. I'm on arch/antergos.



>>> systemctl enable suspend-to-hibernate.service
Failed to enable unit ...to-hibernate.service: Invalid argument


systemd-analyze verify ...hibernate.service responds with an empty output.



I copied the unit file straight from the arch wiki and changed SLEEPLENGTH to 1 hour. How can I debug the issue? How can I make systemd issue more descriptive error messages?



suspend-to-hibernate.service



[Unit]
Description=Delayed hibernation trigger
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279
Documentation=https://wiki.archlinux.org/index.php/Power_management
Conflicts=hibernate.target hybrid-sleep.target
Before=sleep.target
StopWhenUnneeded=true

[Service]
Type=oneshot
RemainAfterExit=yes
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"
Environment="SLEEPLENGTH=+1hour"
ExecStart=-/usr/bin/sh -c 'echo -n "alarm set for "; date +%%s -d$SLEEPLENGTH | tee $WAKEALARM'
ExecStop=-/usr/bin/sh -c '
alarm=$(cat $WAKEALARM);
now=$(date +%%s);
if [ -z "$alarm" ] || [ "$now" -ge "$alarm" ]; then
echo "hibernate triggered";
systemctl hibernate;
else
echo "normal wakeup";
fi;
echo 0 > $WAKEALARM;
'

[Install]
WantedBy=sleep.target






share|improve this question






















  • Where is suspend-to-hibernate.service, and have you run systemctl daemon-reload after creating/modifying that file?
    – muru
    Apr 2 at 4:03










  • suspend-to-hibernate.service sits in a sub-folder of my home folder, from where I also run the commands. I was never able to enable it, so I haven't run systemctl daemon-reload
    – pandita
    Apr 2 at 5:35







  • 1




    As given in the Arch wiki page, the file should be in /etc/systemd/system/, and you have to daemon-reload before enabling it (daemon-reload gets systemd to recheck its directories for new or modified units, and only after than can you enable a new a service).
    – muru
    Apr 2 at 5:38










  • Thanks heaps, this worked. If you sum this up in an answer I'll accept it. I got to say that I find the error message super confusing.... it made me think that there is a syntax error in the file or something like this...
    – pandita
    Apr 2 at 8:41














up vote
1
down vote

favorite












I'm trying to implement the delayed hibernation unit. I'm on arch/antergos.



>>> systemctl enable suspend-to-hibernate.service
Failed to enable unit ...to-hibernate.service: Invalid argument


systemd-analyze verify ...hibernate.service responds with an empty output.



I copied the unit file straight from the arch wiki and changed SLEEPLENGTH to 1 hour. How can I debug the issue? How can I make systemd issue more descriptive error messages?



suspend-to-hibernate.service



[Unit]
Description=Delayed hibernation trigger
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279
Documentation=https://wiki.archlinux.org/index.php/Power_management
Conflicts=hibernate.target hybrid-sleep.target
Before=sleep.target
StopWhenUnneeded=true

[Service]
Type=oneshot
RemainAfterExit=yes
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"
Environment="SLEEPLENGTH=+1hour"
ExecStart=-/usr/bin/sh -c 'echo -n "alarm set for "; date +%%s -d$SLEEPLENGTH | tee $WAKEALARM'
ExecStop=-/usr/bin/sh -c '
alarm=$(cat $WAKEALARM);
now=$(date +%%s);
if [ -z "$alarm" ] || [ "$now" -ge "$alarm" ]; then
echo "hibernate triggered";
systemctl hibernate;
else
echo "normal wakeup";
fi;
echo 0 > $WAKEALARM;
'

[Install]
WantedBy=sleep.target






share|improve this question






















  • Where is suspend-to-hibernate.service, and have you run systemctl daemon-reload after creating/modifying that file?
    – muru
    Apr 2 at 4:03










  • suspend-to-hibernate.service sits in a sub-folder of my home folder, from where I also run the commands. I was never able to enable it, so I haven't run systemctl daemon-reload
    – pandita
    Apr 2 at 5:35







  • 1




    As given in the Arch wiki page, the file should be in /etc/systemd/system/, and you have to daemon-reload before enabling it (daemon-reload gets systemd to recheck its directories for new or modified units, and only after than can you enable a new a service).
    – muru
    Apr 2 at 5:38










  • Thanks heaps, this worked. If you sum this up in an answer I'll accept it. I got to say that I find the error message super confusing.... it made me think that there is a syntax error in the file or something like this...
    – pandita
    Apr 2 at 8:41












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I'm trying to implement the delayed hibernation unit. I'm on arch/antergos.



>>> systemctl enable suspend-to-hibernate.service
Failed to enable unit ...to-hibernate.service: Invalid argument


systemd-analyze verify ...hibernate.service responds with an empty output.



I copied the unit file straight from the arch wiki and changed SLEEPLENGTH to 1 hour. How can I debug the issue? How can I make systemd issue more descriptive error messages?



suspend-to-hibernate.service



[Unit]
Description=Delayed hibernation trigger
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279
Documentation=https://wiki.archlinux.org/index.php/Power_management
Conflicts=hibernate.target hybrid-sleep.target
Before=sleep.target
StopWhenUnneeded=true

[Service]
Type=oneshot
RemainAfterExit=yes
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"
Environment="SLEEPLENGTH=+1hour"
ExecStart=-/usr/bin/sh -c 'echo -n "alarm set for "; date +%%s -d$SLEEPLENGTH | tee $WAKEALARM'
ExecStop=-/usr/bin/sh -c '
alarm=$(cat $WAKEALARM);
now=$(date +%%s);
if [ -z "$alarm" ] || [ "$now" -ge "$alarm" ]; then
echo "hibernate triggered";
systemctl hibernate;
else
echo "normal wakeup";
fi;
echo 0 > $WAKEALARM;
'

[Install]
WantedBy=sleep.target






share|improve this question














I'm trying to implement the delayed hibernation unit. I'm on arch/antergos.



>>> systemctl enable suspend-to-hibernate.service
Failed to enable unit ...to-hibernate.service: Invalid argument


systemd-analyze verify ...hibernate.service responds with an empty output.



I copied the unit file straight from the arch wiki and changed SLEEPLENGTH to 1 hour. How can I debug the issue? How can I make systemd issue more descriptive error messages?



suspend-to-hibernate.service



[Unit]
Description=Delayed hibernation trigger
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279
Documentation=https://wiki.archlinux.org/index.php/Power_management
Conflicts=hibernate.target hybrid-sleep.target
Before=sleep.target
StopWhenUnneeded=true

[Service]
Type=oneshot
RemainAfterExit=yes
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"
Environment="SLEEPLENGTH=+1hour"
ExecStart=-/usr/bin/sh -c 'echo -n "alarm set for "; date +%%s -d$SLEEPLENGTH | tee $WAKEALARM'
ExecStop=-/usr/bin/sh -c '
alarm=$(cat $WAKEALARM);
now=$(date +%%s);
if [ -z "$alarm" ] || [ "$now" -ge "$alarm" ]; then
echo "hibernate triggered";
systemctl hibernate;
else
echo "normal wakeup";
fi;
echo 0 > $WAKEALARM;
'

[Install]
WantedBy=sleep.target








share|improve this question













share|improve this question




share|improve this question








edited Apr 2 at 1:51

























asked Apr 2 at 1:39









pandita

219418




219418











  • Where is suspend-to-hibernate.service, and have you run systemctl daemon-reload after creating/modifying that file?
    – muru
    Apr 2 at 4:03










  • suspend-to-hibernate.service sits in a sub-folder of my home folder, from where I also run the commands. I was never able to enable it, so I haven't run systemctl daemon-reload
    – pandita
    Apr 2 at 5:35







  • 1




    As given in the Arch wiki page, the file should be in /etc/systemd/system/, and you have to daemon-reload before enabling it (daemon-reload gets systemd to recheck its directories for new or modified units, and only after than can you enable a new a service).
    – muru
    Apr 2 at 5:38










  • Thanks heaps, this worked. If you sum this up in an answer I'll accept it. I got to say that I find the error message super confusing.... it made me think that there is a syntax error in the file or something like this...
    – pandita
    Apr 2 at 8:41
















  • Where is suspend-to-hibernate.service, and have you run systemctl daemon-reload after creating/modifying that file?
    – muru
    Apr 2 at 4:03










  • suspend-to-hibernate.service sits in a sub-folder of my home folder, from where I also run the commands. I was never able to enable it, so I haven't run systemctl daemon-reload
    – pandita
    Apr 2 at 5:35







  • 1




    As given in the Arch wiki page, the file should be in /etc/systemd/system/, and you have to daemon-reload before enabling it (daemon-reload gets systemd to recheck its directories for new or modified units, and only after than can you enable a new a service).
    – muru
    Apr 2 at 5:38










  • Thanks heaps, this worked. If you sum this up in an answer I'll accept it. I got to say that I find the error message super confusing.... it made me think that there is a syntax error in the file or something like this...
    – pandita
    Apr 2 at 8:41















Where is suspend-to-hibernate.service, and have you run systemctl daemon-reload after creating/modifying that file?
– muru
Apr 2 at 4:03




Where is suspend-to-hibernate.service, and have you run systemctl daemon-reload after creating/modifying that file?
– muru
Apr 2 at 4:03












suspend-to-hibernate.service sits in a sub-folder of my home folder, from where I also run the commands. I was never able to enable it, so I haven't run systemctl daemon-reload
– pandita
Apr 2 at 5:35





suspend-to-hibernate.service sits in a sub-folder of my home folder, from where I also run the commands. I was never able to enable it, so I haven't run systemctl daemon-reload
– pandita
Apr 2 at 5:35





1




1




As given in the Arch wiki page, the file should be in /etc/systemd/system/, and you have to daemon-reload before enabling it (daemon-reload gets systemd to recheck its directories for new or modified units, and only after than can you enable a new a service).
– muru
Apr 2 at 5:38




As given in the Arch wiki page, the file should be in /etc/systemd/system/, and you have to daemon-reload before enabling it (daemon-reload gets systemd to recheck its directories for new or modified units, and only after than can you enable a new a service).
– muru
Apr 2 at 5:38












Thanks heaps, this worked. If you sum this up in an answer I'll accept it. I got to say that I find the error message super confusing.... it made me think that there is a syntax error in the file or something like this...
– pandita
Apr 2 at 8:41




Thanks heaps, this worked. If you sum this up in an answer I'll accept it. I got to say that I find the error message super confusing.... it made me think that there is a syntax error in the file or something like this...
– pandita
Apr 2 at 8:41










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










As given in the Arch wiki page, the file should be in /etc/systemd/system/. There are several directories where systemd looks for unit files, and /etc/systemd/system/ is where a system administrator should place their service files. See man systemd.unit.



After creating or a modifying a file in these directories, you have to run systemctl daemon-reload, which gets systemd to recheck its directories for new or modified units. Only then can you enable or start a new service.






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f434943%2fsystemd-invalid-argument-debugging-delayed-hibernation-service-file%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    As given in the Arch wiki page, the file should be in /etc/systemd/system/. There are several directories where systemd looks for unit files, and /etc/systemd/system/ is where a system administrator should place their service files. See man systemd.unit.



    After creating or a modifying a file in these directories, you have to run systemctl daemon-reload, which gets systemd to recheck its directories for new or modified units. Only then can you enable or start a new service.






    share|improve this answer
























      up vote
      2
      down vote



      accepted










      As given in the Arch wiki page, the file should be in /etc/systemd/system/. There are several directories where systemd looks for unit files, and /etc/systemd/system/ is where a system administrator should place their service files. See man systemd.unit.



      After creating or a modifying a file in these directories, you have to run systemctl daemon-reload, which gets systemd to recheck its directories for new or modified units. Only then can you enable or start a new service.






      share|improve this answer






















        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        As given in the Arch wiki page, the file should be in /etc/systemd/system/. There are several directories where systemd looks for unit files, and /etc/systemd/system/ is where a system administrator should place their service files. See man systemd.unit.



        After creating or a modifying a file in these directories, you have to run systemctl daemon-reload, which gets systemd to recheck its directories for new or modified units. Only then can you enable or start a new service.






        share|improve this answer












        As given in the Arch wiki page, the file should be in /etc/systemd/system/. There are several directories where systemd looks for unit files, and /etc/systemd/system/ is where a system administrator should place their service files. See man systemd.unit.



        After creating or a modifying a file in these directories, you have to run systemctl daemon-reload, which gets systemd to recheck its directories for new or modified units. Only then can you enable or start a new service.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 2 at 8:45









        muru

        33.3k576141




        33.3k576141






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f434943%2fsystemd-invalid-argument-debugging-delayed-hibernation-service-file%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?