[Solved] bash scrip...
 
Notifications
Clear all

[Solved] bash script doesn't run properly when I detach from screen

0 Posts
1 Users
0 Likes
6 Views
0
Topic starter
Henry Charlesworth Asks: bash script doesn't run properly when I detach from screen
So I have a fairly hacky bash script that I've put together that monitors a particular Python training script (launching/interacting with some blackbox docker containers, which unfortunately have a rare segfault error inside them that can cause the training script to hang). My ugly workaround is because this happens rarely, I just monitor the Python script and check if the current update takes longer than a certain amount of time - if so then close everything and restart the script.

The script works when I test it locally (and seems to work most of the time on the linux Google Cloud machine I've been using), but I've noticed a really strange issue. I run the bash script inside a screen session on the Cloud machine, and everything seems fine. Then I detach and leave it for a while, and if a reset needs to happen it sometimes just seems to stop (it prints out "Timeout reached..." but nothing else). I can see that the CPU usage goes to zero and stays at zero, BUT, if I then open a terminal and reattach to the screen session it suddenly kicks in and starts again. Does anyone have any idea what could be causing something like this?

A reduced version of the bash script is the following:

Code:
#!/bin/bash

export CURR_UPDATE_NUM=0
export PREV_UPDATE_NUM=0

export UPDATE_TIMEOUT=250

rm monitor_update_number.txt > /dev/null
echo $CURR_UPDATE_NUM > monitor_update_number.txt #current update number saved in temporary file. Python modifies this when it finishes an update

#start the main training script:
python -u train.py &

while true; do
  CURR_UPDATE_NUM=$(< monitor_update_number.txt)
  PREV_UPDATE_NUM=$CURR_FRAN_EXPT_UPDATE_NUM

  sleep $UPDATE_TIMEOUT #sleep for time. If python hasn't updated the txt file after this sleep, something is wrong and we restart everything

  CURR_UPDATE_NUM=$(< monitor_update_number.txt)

  if [ $PREV_UPDATE_NUM == $CURR_UPDATE_NUM ]; then
    echo "Timeout reached and update is not completed. Restarting everything and loading the latest save point."

    pkill -9 python
    echo "Killed all Python processes"

    docker kill $(docker ps -a -q)
    echo "Stopped all docker containers."
    docker rm $(docker ps -a -q)

    rm monitor_update_number.txt > /dev/null
    echo $CURR_UPDATE_NUM > monitor_update_number.txt

    python -u train.py --load-from-file &
    echo "Restarted training script"
  fi
done

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Unreplied Posts

[Solved] System Volume Change Observer not working on iOS 15

Gyeom Asks: System Volume Change Observer not working on iOS 15
I used following code to detect system volume changed by users.

Code:
NotificationCenter.default.addObserver(self, selector: #selector(volumeChanged), name: NSNotification.Name(rawValue: "AVSystemController_SystemVolumeDidChangeNotification"), object: nil)

When I updated to iOS 15, I found that this code is not working, but for any previous versions of iOS it works.

I also used an addObserver function, but that is ok.

Is this a iOS 15 bug and if so what can I do to fix it.

thanks :)

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.
 
 
 

[Solved] how do I create Class modules in other class module and passing value for the classes in vba excel

iatnart Asks: how do I create Class modules in other class module and passing value for the classes in vba excel
I have a trouble so I need to create a class modules. Example Condition Room include some property like width, length, height, volume, Window type, Wall type, Roof type, but window, wall, roof either are class module with other properties such as window: glass single layer or double layers, frame wood or alu and so on,… So, how do I create the class module Conditional room consist of other class modules as above Thank you for your help.,

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] REPAST HPC WSL Installation leads to boost no being found

Tom Snow Asks: REPAST HPC WSL Installation leads to boost no being found
When trying to run Repast HPC executables I get the following error:

./main.exe: error while loading shared libraries: libboost_mpi-mt.so.1.61.0: cannot open shared object file: No such file or directory ./main.exe: error while loading shared libraries: libboost_mpi-mt.so.1.61.0: cannot open shared object

In the make file I define the link to boost in an env file with the below:

Code:
BOOST_INCLUDE= -I$(HOME)/sfw/Boost/Boost_1.61/include/
BOOST_LIB_DIR= -L$(HOME)/sfw/Boost/Boost_1.61/lib/

This is linked to a make file with the following make file

Code:
include ./env

.PHONY: clean
clean:
    rm -f *.o
    rm -f *.exe

.PHONY: compile
compile:
    $(MPICXX) $(BOOST_INCLUDE) -c Main.cpp -o Main.o
    $(MPICXX) $(BOOST_LIB_DIR) -o main.exe Main.o $(BOOST_LIBS)

.PHONY: all
all: clean compile

Boost in tsnow@DESKTOP-IF7CEHL:~/sfw/Boost/Boost_1.61/lib$ so it should link well across.

Any help appreciated, just trying to get a tutorial running.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Making Asterisks hollow with only loop, if and two Console.WriteLine() [closed]

CharlieBlake98 Asks: Making Asterisks hollow with only loop, if and two Console.WriteLine() [closed]
Struggling to make this exercise:

Use a loop, an if control block and two Console.WriteLine() statements only, create a C# program to output a hollow 5×5 square of asterisks (‘*’).

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] dummy interface on linux

Edvinas Asks: dummy interface on linux
I need to create a second separate virtual interface on Linux.

I choose dummy. And do these steps:

Code:
$ cat /etc/modules-load.d/dummy.conf
# Load dummy.ko at boot

dummy

Code:
$ cat /etc/sysconfig/network-scripts/ifcfg-ethdummy1
NAME=ethdummy1
DEVICE=ethdummy1
MACADDR=00:22:22:ff:ff:ff
IPADDR=10.10.10.1
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=Ethernet
NM_CONTROLLED=no

Seems like everything works. But on the net I see that people do these lines also:

Code:
$ cat /etc/modprobe.d/dummy.conf 
install dummy /sbin/modprobe --ignore-install dummy; /sbin/ip link set name ethdummy1 dev dummy0

What’s the point of this line ? Thanks.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Debootstrap /usr/sbin/debootstrap: 481: : Permission denied Ubuntu 20.04

Super_X-dev Asks: Debootstrap /usr/sbin/debootstrap: 481: : Permission denied Ubuntu 20.04
I’m trying to create an arm debian rootfs into a Pen Drive which I mounted in /mnt.

I execute:

Code:
sudo debootstrap –arch=armel –foreign stable /mnt

But then it just creates a file in /mnt/-foreign/debootstrap/debootstrap.log which has the following line:

Code:
/usr/sbin/debootstrap: 481: : Permission denied

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Debian 11: Mouse cursor continuous rightward movement, even with mouse disconnected

オパラ Asks: Debian 11: Mouse cursor continuous rightward movement, even with mouse disconnected
Mouse cursor randomly started slowly and continuously moving rightwards, even after disconnecting my mouse it still continued rightwards. I switched user, then switched back to my original user and its fixed now but what might have caused this?
EDIT:
Facing this problem on a desktop computer.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] How to source /etc/profile for Remote Desktop Sessions

Eero Aaltonen Asks: How to source /etc/profile for Remote Desktop Sessions
I want to set up a server with some functions and aliases available for all users.

I set these up initially in a file in /etc/profile.d and everything was working fine both from:

  • SSH
  • Local desktop (Gnome 3)

I then set up Remote Desktop access with xrdp. But the Bash terminals started from within the Remote Desktop environment apparently don’t source /etc/profile.

How could this be achieved in a reasonable manner?

Attempt 1​

I tried to mimic /etc/gdm3/Xsession and added the line

Code:
. /etc/profile

to /etc/X11/Xsession, but that was no good as the Remote Desktop would no longer start.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] Ubuntu 20.04, Firewalld: Am able to SSH from outside of Source Address

Skeer Asks: Ubuntu 20.04, Firewalld: Am able to SSH from outside of Source Address
So I’m going through the setting up local firewalls on linux servers for work. Today I created two new zones: zoneA and zoneB. Zonea has snmp and ssh services added, also has 4 subnets and 1 ip address added as source address. Zoneb has only tcp/443 added with a source address of: target:ACCEPT

Went to test and I get prompted for a password when I attempt to SSH from a host outside of those specified subnets.

Systemctl shows a status if running. Both zones show (active) when I do a –list-all

What did I do wrong here?

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

[Solved] For ppp interface name, get name of lower ethernet/modem connection on Linux 5.x

Alex Stragies Asks: For ppp interface name, get name of lower ethernet/modem connection on Linux 5.x
For a device name, e.g. inet1 of linktype ppp, of which there may be several, how can I get the name of the lower modem/ethernet carrier line/link?

I tried looking in /sys/class/net/$IFACE/, and the ip -d link output.

/proc/$(pidof pppd)/fd/ also didn’t look like it contained something I could use to map the LowerIF/PPPIF tuples. /proc/$pid/cmdline/ can get me the name of the configfile, but that only helps, if I have only one ppp-device.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.

 

 


 

Share: