How do I convert an upstart job to a systemd service?

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











up vote
1
down vote

favorite












I have the following upstart job:



# hwclock - adjust system clock and timezone
#
# The hwclock task adjusts the system clock when the hardware clock is
# set to localtime (e.g. when dual-booting with Windows), and also
# ensures that the system timezone is set so that timestamps are written
# to FAT devices.

description "adjust system clock and timezone"

start on starting mountall

task

script
exec hwclock --systz --utc --noadjfile
end script


I would like to switch this to systemd service.



How should start on starting mountall be implemented on systemd?



I created the systemd service as below, but I do not know how to do start on starting mountall.



[Unit]
Description=hwclock
After=
Before=

[Service]
ExecStart=/sbin/hwclock --systz --utc --noadjfile






share|improve this question




















  • I think that's where the Before= line comes in!
    – George Udosen
    Jan 22 at 5:53










  • It's also probably Type=oneshot, because hwclock will exit when it's done.
    – Ulrich Schwarz
    Jan 22 at 6:05










  • Check out systemd for upstart users and perhaps After=local-fs.target.
    – meuh
    Jan 22 at 9:37














up vote
1
down vote

favorite












I have the following upstart job:



# hwclock - adjust system clock and timezone
#
# The hwclock task adjusts the system clock when the hardware clock is
# set to localtime (e.g. when dual-booting with Windows), and also
# ensures that the system timezone is set so that timestamps are written
# to FAT devices.

description "adjust system clock and timezone"

start on starting mountall

task

script
exec hwclock --systz --utc --noadjfile
end script


I would like to switch this to systemd service.



How should start on starting mountall be implemented on systemd?



I created the systemd service as below, but I do not know how to do start on starting mountall.



[Unit]
Description=hwclock
After=
Before=

[Service]
ExecStart=/sbin/hwclock --systz --utc --noadjfile






share|improve this question




















  • I think that's where the Before= line comes in!
    – George Udosen
    Jan 22 at 5:53










  • It's also probably Type=oneshot, because hwclock will exit when it's done.
    – Ulrich Schwarz
    Jan 22 at 6:05










  • Check out systemd for upstart users and perhaps After=local-fs.target.
    – meuh
    Jan 22 at 9:37












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have the following upstart job:



# hwclock - adjust system clock and timezone
#
# The hwclock task adjusts the system clock when the hardware clock is
# set to localtime (e.g. when dual-booting with Windows), and also
# ensures that the system timezone is set so that timestamps are written
# to FAT devices.

description "adjust system clock and timezone"

start on starting mountall

task

script
exec hwclock --systz --utc --noadjfile
end script


I would like to switch this to systemd service.



How should start on starting mountall be implemented on systemd?



I created the systemd service as below, but I do not know how to do start on starting mountall.



[Unit]
Description=hwclock
After=
Before=

[Service]
ExecStart=/sbin/hwclock --systz --utc --noadjfile






share|improve this question












I have the following upstart job:



# hwclock - adjust system clock and timezone
#
# The hwclock task adjusts the system clock when the hardware clock is
# set to localtime (e.g. when dual-booting with Windows), and also
# ensures that the system timezone is set so that timestamps are written
# to FAT devices.

description "adjust system clock and timezone"

start on starting mountall

task

script
exec hwclock --systz --utc --noadjfile
end script


I would like to switch this to systemd service.



How should start on starting mountall be implemented on systemd?



I created the systemd service as below, but I do not know how to do start on starting mountall.



[Unit]
Description=hwclock
After=
Before=

[Service]
ExecStart=/sbin/hwclock --systz --utc --noadjfile








share|improve this question











share|improve this question




share|improve this question










asked Jan 22 at 5:09









DonBit

334214




334214











  • I think that's where the Before= line comes in!
    – George Udosen
    Jan 22 at 5:53










  • It's also probably Type=oneshot, because hwclock will exit when it's done.
    – Ulrich Schwarz
    Jan 22 at 6:05










  • Check out systemd for upstart users and perhaps After=local-fs.target.
    – meuh
    Jan 22 at 9:37
















  • I think that's where the Before= line comes in!
    – George Udosen
    Jan 22 at 5:53










  • It's also probably Type=oneshot, because hwclock will exit when it's done.
    – Ulrich Schwarz
    Jan 22 at 6:05










  • Check out systemd for upstart users and perhaps After=local-fs.target.
    – meuh
    Jan 22 at 9:37















I think that's where the Before= line comes in!
– George Udosen
Jan 22 at 5:53




I think that's where the Before= line comes in!
– George Udosen
Jan 22 at 5:53












It's also probably Type=oneshot, because hwclock will exit when it's done.
– Ulrich Schwarz
Jan 22 at 6:05




It's also probably Type=oneshot, because hwclock will exit when it's done.
– Ulrich Schwarz
Jan 22 at 6:05












Check out systemd for upstart users and perhaps After=local-fs.target.
– meuh
Jan 22 at 9:37




Check out systemd for upstart users and perhaps After=local-fs.target.
– meuh
Jan 22 at 9:37










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










You will need these lines:



Requires=
After=


As stated here:




Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.



After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.




The structure should be:



[Unit]
Description=hwclock
Requires= # mountall most happen
After= # mountall should have started before hwclock run

[Service]
Type=oneshort
ExecStart=/sbin/hwclock --systz --utc --noadjfile


From here:



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Upstart stanza | systemd unit file directive | systemd unit file section
| |
-------------------------------------------------------------------------
start on | Wants, Requires, Before, |
| After | Unit
--------------------------------------------------------------------------


Note: This is for an Ubuntu system but should be similar. See: https://www.freedesktop.org/software/systemd/man/systemd.unit.html also.






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%2f418749%2fhow-do-i-convert-an-upstart-job-to-a-systemd-service%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
    1
    down vote



    accepted










    You will need these lines:



    Requires=
    After=


    As stated here:




    Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.



    After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.




    The structure should be:



    [Unit]
    Description=hwclock
    Requires= # mountall most happen
    After= # mountall should have started before hwclock run

    [Service]
    Type=oneshort
    ExecStart=/sbin/hwclock --systz --utc --noadjfile


    From here:



    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    Upstart stanza | systemd unit file directive | systemd unit file section
    | |
    -------------------------------------------------------------------------
    start on | Wants, Requires, Before, |
    | After | Unit
    --------------------------------------------------------------------------


    Note: This is for an Ubuntu system but should be similar. See: https://www.freedesktop.org/software/systemd/man/systemd.unit.html also.






    share|improve this answer
























      up vote
      1
      down vote



      accepted










      You will need these lines:



      Requires=
      After=


      As stated here:




      Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.



      After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.




      The structure should be:



      [Unit]
      Description=hwclock
      Requires= # mountall most happen
      After= # mountall should have started before hwclock run

      [Service]
      Type=oneshort
      ExecStart=/sbin/hwclock --systz --utc --noadjfile


      From here:



      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      Upstart stanza | systemd unit file directive | systemd unit file section
      | |
      -------------------------------------------------------------------------
      start on | Wants, Requires, Before, |
      | After | Unit
      --------------------------------------------------------------------------


      Note: This is for an Ubuntu system but should be similar. See: https://www.freedesktop.org/software/systemd/man/systemd.unit.html also.






      share|improve this answer






















        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        You will need these lines:



        Requires=
        After=


        As stated here:




        Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.



        After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.




        The structure should be:



        [Unit]
        Description=hwclock
        Requires= # mountall most happen
        After= # mountall should have started before hwclock run

        [Service]
        Type=oneshort
        ExecStart=/sbin/hwclock --systz --utc --noadjfile


        From here:



        +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Upstart stanza | systemd unit file directive | systemd unit file section
        | |
        -------------------------------------------------------------------------
        start on | Wants, Requires, Before, |
        | After | Unit
        --------------------------------------------------------------------------


        Note: This is for an Ubuntu system but should be similar. See: https://www.freedesktop.org/software/systemd/man/systemd.unit.html also.






        share|improve this answer












        You will need these lines:



        Requires=
        After=


        As stated here:




        Requires=: This directive lists any units upon which this unit essentially depends. If the current unit is activated, the units listed here must successfully activate as well, else this unit will fail. These units are started in parallel with the current unit by default.



        After=: The units listed in this directive will be started before starting the current unit. This does not imply a dependency relationship and one must be established through the above directives if this is required.




        The structure should be:



        [Unit]
        Description=hwclock
        Requires= # mountall most happen
        After= # mountall should have started before hwclock run

        [Service]
        Type=oneshort
        ExecStart=/sbin/hwclock --systz --utc --noadjfile


        From here:



        +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        Upstart stanza | systemd unit file directive | systemd unit file section
        | |
        -------------------------------------------------------------------------
        start on | Wants, Requires, Before, |
        | After | Unit
        --------------------------------------------------------------------------


        Note: This is for an Ubuntu system but should be similar. See: https://www.freedesktop.org/software/systemd/man/systemd.unit.html also.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 22 at 6:31









        George Udosen

        1,112318




        1,112318






















             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f418749%2fhow-do-i-convert-an-upstart-job-to-a-systemd-service%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?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay