The log's order of a script executing before shutdown?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
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.
It is no use at all.
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
shutdown systemd
 |Â
show 5 more comments
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.
It is no use at all.
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
shutdown systemd
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
 |Â
show 5 more comments
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.
It is no use at all.
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
shutdown systemd
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.
It is no use at all.
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
shutdown systemd
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
 |Â
show 5 more comments
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
 |Â
show 5 more comments
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)
add a comment |Â
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)
add a comment |Â
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)
add a comment |Â
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)
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)
edited May 2 at 0:05
answered May 2 at 0:00
![](https://i.stack.imgur.com/Cfz2Q.jpg?s=32&g=1)
![](https://i.stack.imgur.com/Cfz2Q.jpg?s=32&g=1)
Elder Geek
25.3k949120
25.3k949120
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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