The log's order of a script executing before shutdown?

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








up vote
3
down vote

favorite












cat /home/upload.sh 
/usr/bin/scp -P 22 /home/material.gz root@remote_ip:/home
date >> /var/log/upload.log


Setting for upload.service



cat /etc/systemd/system/upload.service
[Unit]
Description=upload files into my vps
Before=shutdown.target reboot.target
Requires=network-online.target
After=network.target

[Service]
ExecStart=/bin/true
ExecStop=/bin/bash /home/upload.sh

[Install]
WantedBy=multi-user.target


The script can upload file into my vps before shutdown.



The strange thing is the upload service's log.



journal -u upload 
Apr 23 12:54:50 localhost systemd[1]: Stopping upload files into my vps...
Apr 23 12:55:13 localhost systemd[1]: Stopped upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Started upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Starting upload files into my vps...


Why it is not such as following order?



Apr 23 12:54:50 localhost systemd[1]: Stopping upload files into my vps...
Apr 23 12:55:13 localhost systemd[1]: Stopped upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Starting upload files into my vps...
Apr 23 12:55:19 localhost systemd[1]: Started upload files into my vps.


Only differ in the last two lines,why?

Which result in this kind of log info?



Do as George Udosen say:Try this in the service file [Unit] Requires=network-online.target After=network.target network-online.target.



my setting



It is no use at all.



log after revise my setting as George Udosen say



lshw -C cpu
*-cpu
product: Intel(R) Xeon(R) CPU E3-1275 v5 @ 3.60GHz
vendor: Intel Corp.
vendor_id: GenuineIntel
physical id: 1
bus info: cpu@0
width: 64 bits
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf cpuid_faulting pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm hwp hwp_noitfy hwp_act_window hwp_epp invpcid_single tpr_shadow vnmi flexpriority ept vpid fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx xsaveopt xsavec xgetbv1 xsaves






share|improve this question






















  • please check your sample output their the same!
    – George Udosen
    Apr 23 at 13:38










  • Pleae take a look at the last two lines.Differ!
    – it_is_a_literature
    Apr 23 at 13:44






  • 1




    Please run this and give the result: systemctl is-enabled NetworkManager-wait-online.service systemd-networkd-wait-online.service
    – George Udosen
    Apr 23 at 14:08






  • 1




    And that is why I said change those lines and see if the order changes!
    – George Udosen
    Apr 23 at 15:32






  • 1




    This seems like a relatively harmless bug because your command is just finishing instantly. Is this causing any weird/unexpected behavior?
    – Kaz Wolfe
    Apr 26 at 7:01














up vote
3
down vote

favorite












cat /home/upload.sh 
/usr/bin/scp -P 22 /home/material.gz root@remote_ip:/home
date >> /var/log/upload.log


Setting for upload.service



cat /etc/systemd/system/upload.service
[Unit]
Description=upload files into my vps
Before=shutdown.target reboot.target
Requires=network-online.target
After=network.target

[Service]
ExecStart=/bin/true
ExecStop=/bin/bash /home/upload.sh

[Install]
WantedBy=multi-user.target


The script can upload file into my vps before shutdown.



The strange thing is the upload service's log.



journal -u upload 
Apr 23 12:54:50 localhost systemd[1]: Stopping upload files into my vps...
Apr 23 12:55:13 localhost systemd[1]: Stopped upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Started upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Starting upload files into my vps...


Why it is not such as following order?



Apr 23 12:54:50 localhost systemd[1]: Stopping upload files into my vps...
Apr 23 12:55:13 localhost systemd[1]: Stopped upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Starting upload files into my vps...
Apr 23 12:55:19 localhost systemd[1]: Started upload files into my vps.


Only differ in the last two lines,why?

Which result in this kind of log info?



Do as George Udosen say:Try this in the service file [Unit] Requires=network-online.target After=network.target network-online.target.



my setting



It is no use at all.



log after revise my setting as George Udosen say



lshw -C cpu
*-cpu
product: Intel(R) Xeon(R) CPU E3-1275 v5 @ 3.60GHz
vendor: Intel Corp.
vendor_id: GenuineIntel
physical id: 1
bus info: cpu@0
width: 64 bits
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf cpuid_faulting pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm hwp hwp_noitfy hwp_act_window hwp_epp invpcid_single tpr_shadow vnmi flexpriority ept vpid fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx xsaveopt xsavec xgetbv1 xsaves






share|improve this question






















  • please check your sample output their the same!
    – George Udosen
    Apr 23 at 13:38










  • Pleae take a look at the last two lines.Differ!
    – it_is_a_literature
    Apr 23 at 13:44






  • 1




    Please run this and give the result: systemctl is-enabled NetworkManager-wait-online.service systemd-networkd-wait-online.service
    – George Udosen
    Apr 23 at 14:08






  • 1




    And that is why I said change those lines and see if the order changes!
    – George Udosen
    Apr 23 at 15:32






  • 1




    This seems like a relatively harmless bug because your command is just finishing instantly. Is this causing any weird/unexpected behavior?
    – Kaz Wolfe
    Apr 26 at 7:01












up vote
3
down vote

favorite









up vote
3
down vote

favorite











cat /home/upload.sh 
/usr/bin/scp -P 22 /home/material.gz root@remote_ip:/home
date >> /var/log/upload.log


Setting for upload.service



cat /etc/systemd/system/upload.service
[Unit]
Description=upload files into my vps
Before=shutdown.target reboot.target
Requires=network-online.target
After=network.target

[Service]
ExecStart=/bin/true
ExecStop=/bin/bash /home/upload.sh

[Install]
WantedBy=multi-user.target


The script can upload file into my vps before shutdown.



The strange thing is the upload service's log.



journal -u upload 
Apr 23 12:54:50 localhost systemd[1]: Stopping upload files into my vps...
Apr 23 12:55:13 localhost systemd[1]: Stopped upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Started upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Starting upload files into my vps...


Why it is not such as following order?



Apr 23 12:54:50 localhost systemd[1]: Stopping upload files into my vps...
Apr 23 12:55:13 localhost systemd[1]: Stopped upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Starting upload files into my vps...
Apr 23 12:55:19 localhost systemd[1]: Started upload files into my vps.


Only differ in the last two lines,why?

Which result in this kind of log info?



Do as George Udosen say:Try this in the service file [Unit] Requires=network-online.target After=network.target network-online.target.



my setting



It is no use at all.



log after revise my setting as George Udosen say



lshw -C cpu
*-cpu
product: Intel(R) Xeon(R) CPU E3-1275 v5 @ 3.60GHz
vendor: Intel Corp.
vendor_id: GenuineIntel
physical id: 1
bus info: cpu@0
width: 64 bits
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf cpuid_faulting pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm hwp hwp_noitfy hwp_act_window hwp_epp invpcid_single tpr_shadow vnmi flexpriority ept vpid fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx xsaveopt xsavec xgetbv1 xsaves






share|improve this question














cat /home/upload.sh 
/usr/bin/scp -P 22 /home/material.gz root@remote_ip:/home
date >> /var/log/upload.log


Setting for upload.service



cat /etc/systemd/system/upload.service
[Unit]
Description=upload files into my vps
Before=shutdown.target reboot.target
Requires=network-online.target
After=network.target

[Service]
ExecStart=/bin/true
ExecStop=/bin/bash /home/upload.sh

[Install]
WantedBy=multi-user.target


The script can upload file into my vps before shutdown.



The strange thing is the upload service's log.



journal -u upload 
Apr 23 12:54:50 localhost systemd[1]: Stopping upload files into my vps...
Apr 23 12:55:13 localhost systemd[1]: Stopped upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Started upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Starting upload files into my vps...


Why it is not such as following order?



Apr 23 12:54:50 localhost systemd[1]: Stopping upload files into my vps...
Apr 23 12:55:13 localhost systemd[1]: Stopped upload files into my vps.
Apr 23 12:55:19 localhost systemd[1]: Starting upload files into my vps...
Apr 23 12:55:19 localhost systemd[1]: Started upload files into my vps.


Only differ in the last two lines,why?

Which result in this kind of log info?



Do as George Udosen say:Try this in the service file [Unit] Requires=network-online.target After=network.target network-online.target.



my setting



It is no use at all.



log after revise my setting as George Udosen say



lshw -C cpu
*-cpu
product: Intel(R) Xeon(R) CPU E3-1275 v5 @ 3.60GHz
vendor: Intel Corp.
vendor_id: GenuineIntel
physical id: 1
bus info: cpu@0
width: 64 bits
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good xtopology nonstop_tsc aperfmperf cpuid_faulting pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch ida arat epb pln pts dtherm hwp hwp_noitfy hwp_act_window hwp_epp invpcid_single tpr_shadow vnmi flexpriority ept vpid fsgsbase bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx xsaveopt xsavec xgetbv1 xsaves








share|improve this question













share|improve this question




share|improve this question








edited May 2 at 0:55

























asked Apr 23 at 13:33









it_is_a_literature

50424




50424











  • please check your sample output their the same!
    – George Udosen
    Apr 23 at 13:38










  • Pleae take a look at the last two lines.Differ!
    – it_is_a_literature
    Apr 23 at 13:44






  • 1




    Please run this and give the result: systemctl is-enabled NetworkManager-wait-online.service systemd-networkd-wait-online.service
    – George Udosen
    Apr 23 at 14:08






  • 1




    And that is why I said change those lines and see if the order changes!
    – George Udosen
    Apr 23 at 15:32






  • 1




    This seems like a relatively harmless bug because your command is just finishing instantly. Is this causing any weird/unexpected behavior?
    – Kaz Wolfe
    Apr 26 at 7:01
















  • please check your sample output their the same!
    – George Udosen
    Apr 23 at 13:38










  • Pleae take a look at the last two lines.Differ!
    – it_is_a_literature
    Apr 23 at 13:44






  • 1




    Please run this and give the result: systemctl is-enabled NetworkManager-wait-online.service systemd-networkd-wait-online.service
    – George Udosen
    Apr 23 at 14:08






  • 1




    And that is why I said change those lines and see if the order changes!
    – George Udosen
    Apr 23 at 15:32






  • 1




    This seems like a relatively harmless bug because your command is just finishing instantly. Is this causing any weird/unexpected behavior?
    – Kaz Wolfe
    Apr 26 at 7:01















please check your sample output their the same!
– George Udosen
Apr 23 at 13:38




please check your sample output their the same!
– George Udosen
Apr 23 at 13:38












Pleae take a look at the last two lines.Differ!
– it_is_a_literature
Apr 23 at 13:44




Pleae take a look at the last two lines.Differ!
– it_is_a_literature
Apr 23 at 13:44




1




1




Please run this and give the result: systemctl is-enabled NetworkManager-wait-online.service systemd-networkd-wait-online.service
– George Udosen
Apr 23 at 14:08




Please run this and give the result: systemctl is-enabled NetworkManager-wait-online.service systemd-networkd-wait-online.service
– George Udosen
Apr 23 at 14:08




1




1




And that is why I said change those lines and see if the order changes!
– George Udosen
Apr 23 at 15:32




And that is why I said change those lines and see if the order changes!
– George Udosen
Apr 23 at 15:32




1




1




This seems like a relatively harmless bug because your command is just finishing instantly. Is this causing any weird/unexpected behavior?
– Kaz Wolfe
Apr 26 at 7:01




This seems like a relatively harmless bug because your command is just finishing instantly. Is this causing any weird/unexpected behavior?
– Kaz Wolfe
Apr 26 at 7:01










1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Based on the information currently available I'm assuming that you have a multi-core or at least multi-threaded CPU and that dispatch and issue decoupling is allowing out-of-order execution, causing this out of order anomaly in log output. I would use numactl to launch your script. Here's an example:



numactl --physcpubind=0 /path/to/your/script



or in this specific case



numactl --physcpubind=0 /home/upload.sh



This will run your process on the first core/cpu assigned to your chipset (index 0) as listed in /proc/cpuinfo This will force the script to run at most one thread concurrently, but it does not mean that the entire process will be composed of only one thread. if the program is written to spawn a new thread, it will do so, but it will execute on the same core/cpu/thread as the rest of the process.



EDIT: Note that by restricting your processing to a single thread/core/cpu this may result in slower processing of the task at hand.



Sources:



https://superuser.com/questions/692138/how-to-force-a-process-to-run-on-a-single-thread-only-with-numactl



man numactl



https://en.wikipedia.org/wiki/Out-of-order_execution



https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "89"
    ;
    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: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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%2faskubuntu.com%2fquestions%2f1027470%2fthe-logs-order-of-a-script-executing-before-shutdown%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
    0
    down vote



    accepted










    Based on the information currently available I'm assuming that you have a multi-core or at least multi-threaded CPU and that dispatch and issue decoupling is allowing out-of-order execution, causing this out of order anomaly in log output. I would use numactl to launch your script. Here's an example:



    numactl --physcpubind=0 /path/to/your/script



    or in this specific case



    numactl --physcpubind=0 /home/upload.sh



    This will run your process on the first core/cpu assigned to your chipset (index 0) as listed in /proc/cpuinfo This will force the script to run at most one thread concurrently, but it does not mean that the entire process will be composed of only one thread. if the program is written to spawn a new thread, it will do so, but it will execute on the same core/cpu/thread as the rest of the process.



    EDIT: Note that by restricting your processing to a single thread/core/cpu this may result in slower processing of the task at hand.



    Sources:



    https://superuser.com/questions/692138/how-to-force-a-process-to-run-on-a-single-thread-only-with-numactl



    man numactl



    https://en.wikipedia.org/wiki/Out-of-order_execution



    https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)






    share|improve this answer


























      up vote
      0
      down vote



      accepted










      Based on the information currently available I'm assuming that you have a multi-core or at least multi-threaded CPU and that dispatch and issue decoupling is allowing out-of-order execution, causing this out of order anomaly in log output. I would use numactl to launch your script. Here's an example:



      numactl --physcpubind=0 /path/to/your/script



      or in this specific case



      numactl --physcpubind=0 /home/upload.sh



      This will run your process on the first core/cpu assigned to your chipset (index 0) as listed in /proc/cpuinfo This will force the script to run at most one thread concurrently, but it does not mean that the entire process will be composed of only one thread. if the program is written to spawn a new thread, it will do so, but it will execute on the same core/cpu/thread as the rest of the process.



      EDIT: Note that by restricting your processing to a single thread/core/cpu this may result in slower processing of the task at hand.



      Sources:



      https://superuser.com/questions/692138/how-to-force-a-process-to-run-on-a-single-thread-only-with-numactl



      man numactl



      https://en.wikipedia.org/wiki/Out-of-order_execution



      https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)






      share|improve this answer
























        up vote
        0
        down vote



        accepted







        up vote
        0
        down vote



        accepted






        Based on the information currently available I'm assuming that you have a multi-core or at least multi-threaded CPU and that dispatch and issue decoupling is allowing out-of-order execution, causing this out of order anomaly in log output. I would use numactl to launch your script. Here's an example:



        numactl --physcpubind=0 /path/to/your/script



        or in this specific case



        numactl --physcpubind=0 /home/upload.sh



        This will run your process on the first core/cpu assigned to your chipset (index 0) as listed in /proc/cpuinfo This will force the script to run at most one thread concurrently, but it does not mean that the entire process will be composed of only one thread. if the program is written to spawn a new thread, it will do so, but it will execute on the same core/cpu/thread as the rest of the process.



        EDIT: Note that by restricting your processing to a single thread/core/cpu this may result in slower processing of the task at hand.



        Sources:



        https://superuser.com/questions/692138/how-to-force-a-process-to-run-on-a-single-thread-only-with-numactl



        man numactl



        https://en.wikipedia.org/wiki/Out-of-order_execution



        https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)






        share|improve this answer














        Based on the information currently available I'm assuming that you have a multi-core or at least multi-threaded CPU and that dispatch and issue decoupling is allowing out-of-order execution, causing this out of order anomaly in log output. I would use numactl to launch your script. Here's an example:



        numactl --physcpubind=0 /path/to/your/script



        or in this specific case



        numactl --physcpubind=0 /home/upload.sh



        This will run your process on the first core/cpu assigned to your chipset (index 0) as listed in /proc/cpuinfo This will force the script to run at most one thread concurrently, but it does not mean that the entire process will be composed of only one thread. if the program is written to spawn a new thread, it will do so, but it will execute on the same core/cpu/thread as the rest of the process.



        EDIT: Note that by restricting your processing to a single thread/core/cpu this may result in slower processing of the task at hand.



        Sources:



        https://superuser.com/questions/692138/how-to-force-a-process-to-run-on-a-single-thread-only-with-numactl



        man numactl



        https://en.wikipedia.org/wiki/Out-of-order_execution



        https://en.wikipedia.org/wiki/Multithreading_(computer_architecture)







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 2 at 0:05

























        answered May 2 at 0:00









        Elder Geek

        25.3k949120




        25.3k949120



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1027470%2fthe-logs-order-of-a-script-executing-before-shutdown%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            pylint3 and pip3 broken

            Missing snmpget and snmpwalk

            How to enroll fingerprints to Ubuntu 17.10 with VFS491