Spark-Submit command takes a while to run - apache-spark
We have installed Apache Hadoop and Spark on a cluster of servers running on IBM AIX (version 2) OS.
Hadoop version - hadoop-3.2.1
Spark version - spark-3.0.1
We are testing the overall install of Spark by running the spark-submit --version command found under $SPARK_HOME/bin folder. This command runs intermittently. When you run it the first time, the command runs with no delay. Running the command multiple times afterwards takes a long time to execute (around 30 - 40 minutes). We have checked the server CPU and memory - there is no issues with low memory or applications hogging the resources of the processor. We are not able to pinpoint where the delay is when this command runs.
This Hadoop/Spark setup is working in a cluster running Red Hat 7.9. We do not face this issue in this environment.
This is my first time asking a question on Stack Overflow. Please let me know if there is anymore information I need to provide.
Thanks in advance.
===========================
Edit May 11th:
Successful log run (debug lines were added in the spark-submit command)
bash-5.0$ spark-submit --version
Entered spark submit
About to execute spark submit command.....
About to load spark env.sh
Loaded spark env.sh
Entered statement to create RUNNER
searching spark_home/jars
Loaded spark jars DIR
Launching class path
Launched class path
Entering build command
Completed build command
About to enter while block
Entered while block for Entered build command
Entered build command
CMD is
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for
For changing delim to blank
CMD is
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for /u01/app/java8_64/bin/java
Entered if condition for /u01/app/java8_64/bin/java
CMD is /u01/app/java8_64/bin/java
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for -cp
Entered if condition for -cp
CMD is /u01/app/java8_64/bin/java -cp
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/
Entered if condition for /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for -Xmx1g
Entered if condition for -Xmx1g
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for org.apache.spark.deploy.SparkSubmit
Entered if condition for org.apache.spark.deploy.SparkSubmit
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g org.apache.spark.deploy.SparkSubmit
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for --version
Entered if condition for --version
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g org.apache.spark.deploy.SparkSubmit --version
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for 0
Entered if condition for 0
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g org.apache.spark.deploy.SparkSubmit --version 0
build_command is and org.apache.spark.deploy.SparkSubmit --version
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g org.apache.spark.deploy.SparkSubmit --version 0
completed while block
About to execute /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g
org.apache.spark.deploy.SparkSubmit --version
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 3.0.1
/_/
Using Scala version 2.12.10, IBM J9 VM, 1.8.0_251
Branch HEAD
Compiled by user ubuntu on 2020-08-28T08:58:35Z
Revision 2b147c4cd50da32fe2b4167f97c8142102a0510d
Url https://gitbox.apache.org/repos/asf/spark.git
Type --help for more information.
=============================================================
Failed run:
bash-5.0$ spark-submit --version
Entered spark submit
About to execute spark submit command.....
About to load spark env.sh
Loaded spark env.sh
Entered statement to create RUNNER
searching spark_home/jars
Loaded spark jars DIR
Launching class path
Launched class path
Entering build command
Completed build command
About to enter while block
Entered while block for Entered build command
Entered build command
CMD is
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for
For changing delim to blank
CMD is
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for /u01/app/java8_64/bin/java
Entered if condition for /u01/app/java8_64/bin/java
CMD is /u01/app/java8_64/bin/java
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for -cp
Entered if condition for -cp
CMD is /u01/app/java8_64/bin/java -cp
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/
Entered if condition for /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for -Xmx1g
Entered if condition for -Xmx1g
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for org.apache.spark.deploy.SparkSubmit
Entered if condition for org.apache.spark.deploy.SparkSubmit
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g org.apache.spark.deploy.SparkSubmit
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for --version
Entered if condition for --version
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g org.apache.spark.deploy.SparkSubmit --version
build_command is and org.apache.spark.deploy.SparkSubmit --version
Entered while block for 0
Entered if condition for 0
CMD is /u01/app/java8_64/bin/java -cp /u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/conf/:/u01/app/rmb/ria/AnthemSpark/spark-3.0.1-bin-hadoop3.2/jars/*:/u01/app/rmb/ria/AnthemSpark/hadoop-3.2.1/etc/hadoop/ -Xmx1g org.apache.spark.deploy.SparkSubmit --version 0
build_command is and org.apache.spark.deploy.SparkSubmit --version
##########################
EDIT - March 12th
This is the last few lines when running the following command - truss -d. The last output shows it going into "sleep".
0.9063: lseek(0, 0, 1) Err#29 ESPIPE
0.9066: fstatx(0, 0x0FFFFFFFFFFFE8F8, 176, 0) = 0
0.9068: _sigaction(14, 0x0FFFFFFFFFFFE710, 0x0FFFFFFFFFFFE740) = 0
0.9071: incinterval(0, 0x0FFFFFFFFFFFE640, 0x0FFFFFFFFFFFE660) = 0
0.9073: kread(0, " o", 1) = 1
0.9075: kread(0, " r", 1) = 1
0.9078: kread(0, " g", 1) = 1
0.9080: kread(0, " .", 1) = 1
0.9082: kread(0, " a", 1) = 1
0.9084: kread(0, " p", 1) = 1
0.9086: kread(0, " a", 1) = 1
0.9089: kread(0, " c", 1) = 1
0.9091: kread(0, " h", 1) = 1
0.9093: kread(0, " e", 1) = 1
0.9095: kread(0, " .", 1) = 1
0.9097: kread(0, " s", 1) = 1
0.9100: kread(0, " p", 1) = 1
0.9102: kread(0, " a", 1) = 1
0.9104: kread(0, " r", 1) = 1
0.9106: kread(0, " k", 1) = 1
0.9108: kread(0, " .", 1) = 1
0.9111: kread(0, " d", 1) = 1
0.9113: kread(0, " e", 1) = 1
0.9115: kread(0, " p", 1) = 1
0.9117: kread(0, " l", 1) = 1
0.9119: kread(0, " o", 1) = 1
0.9122: kread(0, " y", 1) = 1
0.9124: kread(0, " .", 1) = 1
0.9126: kread(0, " S", 1) = 1
0.9128: kread(0, " p", 1) = 1
0.9130: kread(0, " a", 1) = 1
0.9132: kread(0, " r", 1) = 1
0.9135: kread(0, " k", 1) = 1
0.9137: kread(0, " S", 1) = 1
0.9139: kread(0, " u", 1) = 1
0.9141: kread(0, " b", 1) = 1
0.9143: kread(0, " m", 1) = 1
0.9187: kread(0, " i", 1) = 1
0.9190: kread(0, " t", 1) = 1
0.9192: kread(0, "\0", 1) = 1
0.9195: incinterval(0, 0x0FFFFFFFFFFFE5C0, 0x0FFFFFFFFFFFE5E0) = 0
0.9197: _sigaction(14, 0x0FFFFFFFFFFFE690, 0x0FFFFFFFFFFFE6C0) = 0
0.9200: kfcntl(1, F_GETFL, 0x0000000000000000) = 67110914
0.9204: kfcntl(1, F_GETFL, 0x0000000000000000) = 67110914
0.9207: kioctl(0, 22528, 0x0000000000000000, 0x0000000000000000) Err#25 ENOTTY
0.9211: lseek(0, 0, 1) Err#29 ESPIPE
0.9214: fstatx(0, 0x0FFFFFFFFFFFE8F8, 176, 0) = 0
0.9216: _sigaction(14, 0x0FFFFFFFFFFFE710, 0x0FFFFFFFFFFFE740) = 0
0.9219: incinterval(0, 0x0FFFFFFFFFFFE640, 0x0FFFFFFFFFFFE660) = 0
0.9222: kread(0, " -", 1) = 1
0.9224: kread(0, " -", 1) = 1
0.9227: kread(0, " v", 1) = 1
0.9229: kread(0, " e", 1) = 1
0.9231: kread(0, " r", 1) = 1
0.9234: kread(0, " s", 1) = 1
0.9236: kread(0, " i", 1) = 1
0.9238: kread(0, " o", 1) = 1
0.9241: kread(0, " n", 1) = 1
0.9243: kread(0, "\0", 1) = 1
0.9245: incinterval(0, 0x0FFFFFFFFFFFE5C0, 0x0FFFFFFFFFFFE5E0) = 0
0.9248: _sigaction(14, 0x0FFFFFFFFFFFE690, 0x0FFFFFFFFFFFE6C0) = 0
0.9251: kfcntl(1, F_GETFL, 0x0000000000000000) = 67110914
0.9254: kfcntl(1, F_GETFL, 0x0000000000000000) = 67110914
0.9257: kioctl(0, 22528, 0x0000000000000000, 0x0000000000000000) Err#25 ENOTTY
0.9260: lseek(0, 0, 1) Err#29 ESPIPE
0.9262: fstatx(0, 0x0FFFFFFFFFFFE8F8, 176, 0) = 0
0.9265: _sigaction(14, 0x0FFFFFFFFFFFE710, 0x0FFFFFFFFFFFE740) = 0
0.9268: incinterval(0, 0x0FFFFFFFFFFFE640, 0x0FFFFFFFFFFFE660) = 0
0.9270: kread(0, " 0", 1) = 1
0.9273: kread(0, "\0", 1) = 1
0.9275: incinterval(0, 0x0FFFFFFFFFFFE5C0, 0x0FFFFFFFFFFFE5E0) = 0
0.9278: _sigaction(14, 0x0FFFFFFFFFFFE690, 0x0FFFFFFFFFFFE6C0) = 0
0.9281: kfcntl(1, F_GETFL, 0x0000000000000000) = 67110914
0.9284: kfcntl(1, F_GETFL, 0x0000000000000020) = 67110914
0.9287: kioctl(0, 22528, 0x0000000000000000, 0x0000000000000000) Err#25 ENOTTY
0.9290: lseek(0, 0, 1) Err#29 ESPIPE
0.9292: fstatx(0, 0x0FFFFFFFFFFFE8F8, 176, 0) = 0
0.9295: _sigaction(14, 0x0FFFFFFFFFFFE710, 0x0FFFFFFFFFFFE740) = 0
0.9297: incinterval(0, 0x0FFFFFFFFFFFE640, 0x0FFFFFFFFFFFE660) = 0
2.9303: kread(0, "\t", 1) (sleeping...)
#LorinczyZsigmond's suggestion ended up steering us in the right place. Searching with the last line - kread(0, "\t", 1) (sleeping...) - led us to Issue with Bash read builtin in latest release where there was chatter about others having the same issue with that version released on the IBM AIX Linux Toolbox website. After updating to version 5.1.4.2, the issue went away and we were able to finish the script.
Related
adding osmosdr for gnuradio in recipe Yocto Raspberry pi 4
I'm trying to create a yocto recipe to add osmosdr on my raspberrypi 4 but I get the following error when I generate my image: /home/norian/Yocto/build-rpi/tmp/work/cortexa72-poky-linux/uhd/3.15.LTS-r0/git/host/lib/rfnoc/dma_fifo_block_ctrl_impl.cpp:61:21: error: '_1' was not declared in this scope Here is my recipe: SUMMARY = "A small image just capable of allowing a device to boot." IMAGE_LINGUAS = " " LICENSE = "MIT" inherit core-image CORE_IMAGE_EXTRA_INSTALL = "\ packagegroup-sdr-base-extended \ packagegroup-sdr-base-debug \ packagegroup-sdr-base-devel \ packagegroup-sdr-base-python \ packagegroup-sdr-python-extended \ packagegroup-sdr-gnuradio-base \ packagegroup-core-eclipse-debug \ " RPI_EXTRA_CONFIG = "\ force_turbo=0 \n \ arm_freq=700 \n \ arm_freq_min=100 \ " IMAGE_INSTALL += "nano" IMAGE_INSTALL += "gr-osmosdr" CONF_VERSION = "1" ENABLE_UART="1" DISABLE_SPLASH = "1" DISABLE_RPI_BOOT_LOGO = "1" I am using Ubuntu 20.04. My version of poky is : DISTRO_VERSION = "3.3.4" DISTRO_CODENAME = "hardknott" Do you know how to resolve this?
Make a shell pipeline started from subprocess.Popen fail if the left-hand side of a pipe fails
Im running a bash command with subprocess.popen in python: cmd = "bwa-mem2/bwa-mem2 mem -R \'#RG\\tID:2064-01\\tSM:2064-01\\tLB:2064-01\\tPL:ILLUMINA\\tPU:2064-01\' reference_genome/human_g1k_v37.fasta BHYHT7CCXY.RJ-1967-987-02.2_1.fastq BHYHT7CCXY.RJ-1967-987-02.2_2.fastq -t 14 | samtools view -bS -o dna_seq/aligned/2064-01/2064-01.6.bam -" process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) The problem is that I get returncode 0 even if the first command fails. I have googled and found out about pipefail and it seems that this is what I should use. However, I don't understand where to write it. I have tried: "set -o pipefail && bwa-mem2/bwa-mem2 mem -R \'#RG\\tID:2064-01\\tSM:2064-01\\tLB:2064-01\\tPL:ILLUMINA\\tPU:2064-01\' reference_genome/human_g1k_v37.fasta BHYHT7CCXY.RJ-1967-987-02.2_1.fastq BHYHT7CCXY.RJ-1967-987-02.2_2.fastq -t 14 | samtools view -bS -o dna_seq/aligned/2064-01/2064-01.6.bam -" which gives: /bin/sh: 1: set: Illegal option -o pipefail any ideas how I should incorporate this? Edit: I'm not sure if it is correct to edit my answer when responding to an answer? there was not enough characters to respond in a comment:/ Anyway, I tried your second approach without shell=True #Charles Duffy. (cmd_1 and cmd_2 are equal to what you wrote in your solution) This is the code I use: try: p1 = Popen(shlex.split(cmd_1), stdout=PIPE) p2 = Popen(shlex.split(cmd_2), stdin=p1.stdout, stdout=PIPE, stderr=STDOUT, text=True) p1.stdout.close() output, error = p2.communicate() p1.wait() rc_1 = p1.poll() rc_2 = p2.poll() print("rc_1:", rc_1) print("rc_2:", rc_2) if rc_1 == 0 and rc_2 == 0: self.log_to_file("DEBUG", "# Process ended with returncode = 0") if text: self.log_to_file("INFO", f"{text} succesfully else: print("Raise exception") raise Exception(f"stdout: {output} stderr: {error}") except Exception as e: print(f"Error: {e} in misc.run_command()") self.log_to_file("ERROR", f"# Process ended with returncode != 0, {e}") this is the result i get when deliberately causing an error by renaming one file: [E::main_mem] failed to open file `/home/jonas/BASE/dna_seq/reads/2064-01/test_BHYHT7CCXY.RJ-1967-987-02.2_2.fastq.gz'. free(): double free detected in tcache 2 rc_1: -6 rc_2: 0 Raise exception Error: stdout: stderr: None in misc.run_command() ERROR: # Process ended with returncode != 0, stdout: stderr: None It seems to capture the faulty returncode. But why is stdout empty and stderr= None? How can I capture the output to have it logged to a logger both when the process is successful and when it fails?
First, With A Shell Instead of letting shell=True specify sh by default, specify bash explicitly to ensure that pipefail is an available feature: shell_script = r''' set -o pipefail || exit bwa-mem2/bwa-mem2 mem \ -R '#RG\tID:2064-01\tSM:2064-01\tLB:2064-01\tPL:ILLUMINA\tPU:2064-01' \ reference_genome/human_g1k_v37.fasta \ BHYHT7CCXY.RJ-1967-987-02.2_1.fastq \ BHYHT7CCXY.RJ-1967-987-02.2_2.fastq \ -t 14 \ | samtools view -bS \ -o dna_seq/aligned/2064-01/2064-01.6.bam - ''' process = subprocess.Popen(["bash", "-c", shell_script], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) This works, but it's not the best available option. Second, With No Shell At All p1 = subprocess.Popen( ['bwa-mem2/bwa-mem2', 'mem', '-R', r'#RG\tID:2064-01\tSM:2064-01\tLB:2064-01\tPL:ILLUMINA\tPU:2064-01', 'reference_genome/human_g1k_v37.fasta', 'BHYHT7CCXY.RJ-1967-987-02.2_1.fastq', 'BHYHT7CCXY.RJ-1967-987-02.2_2.fastq', '-t', '14'], stdout=subprocess.PIPE) p2 = subprocess.Popen( ['samtools', 'view', '-bS', '-o', 'dna_seq/aligned/2064-01/2064-01.6.bam', '-'], stdin=p1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) p1.stdout.close() output, _ = p2.communicate() # let p2 finish running p1.wait() # ensure p1 has properly exited print(f'bwa-mem2 exited with status {p1.returncode}') print(f'samtools exited with status {p2.returncode}') ...which lets you check p1.returncode and p2.returncode separately.
Bash Script to kill linux processes not coming back to terminal
I am new to Linux environment and working on writing scripts to start and stop few services(nodejs app bundled into executables using 'pkg' module). I want to stop processes by name and found 'killall' command. I tried this command individuaaly and inside bash script. Problem I am facing is, after executing kill command, control does not comeback to terminal and i need to use ctrl+c to get terminal back. Here is script i tried: #!/bin/bash # Run with command : chmod +x /root/myApp/stopserv.sh && /root/myApp/stopserv.sh echo "Stopping Service1" nohup killall Service1 &>/dev/null & echo "Stopping Service2" nohup killall Service2 &>/dev/null & echo "Stopping Service3" nohup killall Service3 &>/dev/null & echo "Stopping Service4" nohup killall Service4 &>/dev/null & And when i run this script, I get response on terminal like below: root#Phantom-E03E:~/myApp# chmod +x /root/myApp/stopserv.sh && /root/myApp/stopserv.sh Stopping Service1 Stopping Service2 Stopping Service3 Stopping Service4 root#Phantom-E03E:~/myApp# /root/myApp/startserv.sh: line 17: 29535 Terminated nohup ./Service1 &> /dev/null /root/myApp/startserv.sh: line 11: 29533 Terminated nohup ./Service2-linux &> /dev/null /root/myApp/startserv.sh: line 14: 29534 Terminated nohup ./Service3-linux &> /dev/null /root/myApp/startserv.sh: line 8: 29527 Terminated nohup ./Service4-linux &> /dev/null I want to check: Is there any other recommended way to stop executables in linux by name? How to i get control back to terminal "root#Phantom-E03E:~/myApp#" after running script? Thanks, Pooja
Just call the script like: <path_to_script> && exit
You can do it much better. Actually you can do it in two ways 1. using foreground-background mechanism 2. using systemd - service management ( a lit bit complicated ) using fg / bg When we run a process using shell (? bash) it will have interactively with our terminal. We can manage this interactivity by Control-Z (stop it, not quit, just pause) Control-C (stop it, kill == quit) fg ( bringing it back to foreground == interactivity ) bg ( running it in background when it is stopped ) You can use this way manually or using a script. I will show both. here is a screen-shot of doing manually using bash here is a simple script #!/bin/bash APP_STATE=$1; APP_NAME=$2; # TASKS=( cont stop ); function stop_app(){ APP_PID=$(pidof $APP_NAME); kill -n 19 $APP_PID; if [[ $? == '0' ]]; then echo "$APP_NAME paused!"; else echo "could not pause $APP_NAME"; fi } function continue_app(){ APP_PID=$(pidof $APP_NAME); kill -n 18 $APP_PID; if [[ $? == '0' ]]; then echo "$APP_NAME continued ..."; else echo "could not continue $APP_NAME"; fi } case $APP_STATE in cont ) continue_app ;; stop ) stop_app ;; esac and screen-shot of running this script Note bg and fg are interfaces and you can do it in lower level using kill command by sending stop signal and continue signal which my script does it this way. >>> kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM 16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP 21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ 26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR 31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3 38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8 43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13 48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12 53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7 58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2 63) SIGRTMAX-1 64) SIGRTMAX please notice signals 18 and 19. For a simple killing a process by name use pkill command. For a complex management please take look at /etc/systemd/system directory And if you have a Node.js server up and running and its management use either of pm2 or systemd
Yocto fails to boot after adding package
I'm about to build a Linux-Yocto filesystem for Xilinx Zynq platform. Everything runs fine until I added one more package to the rootfs. It doesn't matter what kind of package I'm adding it always fails with: INIT: version 2.88 booting /etc/init.d/rcS: line 17: mount: command not found /etc/init.d/rc: line 66: stty: command not found /etc/rcS.d/S02banner.sh: line 11: /bin/mknod: No such file or directory /etc/rcS.d/S02sysfs.sh: line 14: mount: command not found /etc/rcS.d/S02sysfs.sh: line 17: grep: command not found /etc/rcS.d/S06checkroot.sh: line 142: mount: command not found /etc/rcS.d/S06checkroot.sh: line 145: ln: command not found Starting Bootlog daemon: bootlogd: cannot find console device 249:0 under /dev bootlogd. /etc/rcS.d/S37populate-volatile.sh: line 12: dirname: command not found /etc/rcS.d/S37populate-volatile.sh: line 13: sed: command not found /etc/rcS.d/S37populate-volatile.sh: line 193: /proc/cmdline: No such file or directory /etc/rcS.d/S38devpts.sh: line 13: grep: command not found /etc/rcS.d/S38dmesg.sh: line 17: dmesg: command not found /etc/rcS.d/S39hostname.sh: line 10: /bin/hostname: No such file or directory /etc/rcS.d/S39hostname.sh: line 19: hostname: command not found /etc/rcS.d/S55bootmisc.sh: line 64: date: command not found /etc/rcS.d/S55bootmisc.sh: l INIT: Entering runlevel: 5 /etc/init.d/rc: line 66: stty: command not found Starting ntpd: /etc/rc5.d/S20ntpd: line 42: start-stop-daemon: command not found done Stopping Bootlog daemon: /etc/rc5.d/S99stop-bootlogd: line 62: start-stop-daemon: command not found bootlogd. And: INIT: cannot execute "/sbin/getty"cannot execute "/sbin/getty" INIT: Id "1" respawning too fast: disabled for 5 minutes INIT: cannot execute "/sbin/getty" INIT: Id "PS0" respawning too fast: disabled for 5 minutes My local.conf: MACHINE ?= "zedboard-zynq7" DISTRO ?= "poky" EXTRA_IMAGE_FEATURES = "debug-tweaks" USER_CLASSES ?= "buildstats image-mklibs image-prelink" PATCHRESOLVE = "noop" BB_DISKMON_DIRS = "\ STOPTASKS,${TMPDIR},1G,100K \ STOPTASKS,${DL_DIR},1G,100K \ STOPTASKS,${SSTATE_DIR},1G,100K \ ABORT,${TMPDIR},100M,1K \ ABORT,${DL_DIR},100M,1K \ ABORT,${SSTATE_DIR},100M,1K" PACKAGECONFIG_pn-qemu-native = "sdl" PACKAGECONFIG_pn-nativesdk-qemu = "sdl" ASSUME_PROVIDED += "libsdl-native" CONF_VERSION = "1" #AT-ubifs config MKUBIFS_ARGS = "-m 2048 -e 126976 -c 1884" #added by hob PACKAGE_CLASSES = "package_rpm " #added by hob DL_DIR = "/home/jonas/Zynq_AT_Debug/Yocto/poky/build/downloads" #added by hob SSTATE_DIR = "/home/jonas/Zynq_AT_Debug/Yocto/poky/build/sstate-cache" #added by hob SSTATE_MIRRORS = "" #added by hob PARALLEL_MAKE = "-j 8" #added by hob BB_NUMBER_THREADS = "8" #added by hob INCOMPATIBLE_LICENSE = "" #added by hob SDKMACHINE = "x86_64" #added by hob http_proxy = "" #added by hob https_proxy = "" #added by hob ftp_proxy = "" #added by hob all_proxy = "" #added by hob CVS_PROXY_HOST = "" #added by hob CVS_PROXY_PORT = "" #added by hob IMAGE_EXTRA_SPACE = "0" #added by hob TOOLCHAIN_BUILD = "False" #added by hob IMAGE_FSTYPES = "ubifs cpio" #added by hob LINGUAS_INSTALL = "" My Image recipe: require /home/jonas/Zynq_AT_Debug/Yocto/poky/meta/recipes-core/images/core-image-minimal.bb IMAGE_INSTALL = "sysvinit-pidof \ update-alternatives-opkg shadow-securetty init-ifupdown \ initscripts-functions base-files update-rc.d \ run-postinsts openssh udev-cache zlib libcrypto \ util-linux-libblkid openssh-scp openssh-keygen \ mtd-utils-ubifs initscripts openssh-ssh \ udev-utils modutils-initscripts eglibc \ shadow netbase openssh-sshd udev base-passwd \ sysvinit mtd-utils openssl-conf libkmod lzo \ util-linux-libuuid libwrap sysvinit-inittab \ iperf nbench-byte ntp ntpdate nano" DESCRIPTION = "***** Yocto-filesystem" If I take out nano everything is fine. I hope someone can help me.
To add more package into the rootfs, in conf/local.conf add this line: IMAGE_INSTALL_append = " nano" The space in front is really important. In addition, please show where you get your bsp and your conf/bblayers.conf Edit: Let's start from the beginning. Copy this, replace my local.conf to yours local.conf. With this minimal set up, you could at least bitbake core-image-minimal Then, to add your packages into the image, just add them to IMAGE_INSTALL_append = " " MACHINE ?= "zedboard-zynq7" DISTRO ?= "poky" EXTRA_IMAGE_FEATURES = "debug-tweaks ssh-server-openssh package-manager" USER_CLASSES ?= "buildstats image-mklibs image-prelink" PATCHRESOLVE = "noop" BB_DISKMON_DIRS = "\ STOPTASKS,${TMPDIR},1G,100K \ STOPTASKS,${DL_DIR},1G,100K \ STOPTASKS,${SSTATE_DIR},1G,100K \ ABORT,${TMPDIR},100M,1K \ ABORT,${DL_DIR},100M,1K \ ABORT,${SSTATE_DIR},100M,1K" PACKAGECONFIG_pn-qemu-native = "sdl" PACKAGECONFIG_pn-nativesdk-qemu = "sdl" ASSUME_PROVIDED += "libsdl-native" CONF_VERSION = "1" #AT-ubifs config MKUBIFS_ARGS = "-m 2048 -e 126976 -c 1884" PACKAGE_CLASSES = "package_rpm " DL_DIR = "/home/jonas/Zynq_AT_Debug/Yocto/poky/build/downloads" SSTATE_DIR = "/home/jonas/Zynq_AT_Debug/Yocto/poky/build/sstate-cache" SSTATE_MIRRORS = "" PARALLEL_MAKE = "-j ${#oe.utils.cpu_count()}" BB_NUMBER_THREADS = "${#oe.utils.cpu_count()}" SDKMACHINE = "x86_64" IMAGE_FSTYPES = "ubifs cpio" IMAGE_INSTALL_append = " nano smartpm openssh-sftp-server "
Capture both exit status and output from a system call in R
I've been playing a bit with system() and system2() for fun, and it struck me that I can save either the output or the exit status in an object. A toy example: X <- system("ping google.com",intern=TRUE) gives me the output, whereas X <- system2("ping", "google.com") gives me the exit status (1 in this case, google doesn't take ping). If I want both the output and the exit status, I have to do 2 system calls, which seems a bit overkill. How can I get both with using only one system call? EDIT : I'd like to have both in the console, if possible without going over a temporary file by using stdout="somefile.ext" in the system2 call and subsequently reading it in.
As of R 2.15, system2 will give the return value as an attribute when stdout and/or stderr are TRUE. This makes it easy to get the text output and return value. In this example, ret ends up being a string with an attribute "status": > ret <- system2("ls","xx", stdout=TRUE, stderr=TRUE) Warning message: running command ''ls' xx 2>&1' had status 1 > ret [1] "ls: xx: No such file or directory" attr(,"status") [1] 1 > attr(ret, "status") [1] 1
I am a bit confused by your description of system2, because it has stdout and stderr arguments. So it is able to return both exit status, stdout and stderr. > out <- tryCatch(ex <- system2("ls","xx", stdout=TRUE, stderr=TRUE), warning=function(w){w}) > out <simpleWarning: running command ''ls' xx 2>&1' had status 2> > ex [1] "ls: cannot access xx: No such file or directory" > out <- tryCatch(ex <- system2("ls","-l", stdout=TRUE, stderr=TRUE), warning=function(w){w}) > out [listing snipped] > ex [listing snipped]
I suggest using this function here: robust.system <- function (cmd) { stderrFile = tempfile(pattern="R_robust.system_stderr", fileext=as.character(Sys.getpid())) stdoutFile = tempfile(pattern="R_robust.system_stdout", fileext=as.character(Sys.getpid())) retval = list() retval$exitStatus = system(paste0(cmd, " 2> ", shQuote(stderrFile), " > ", shQuote(stdoutFile))) retval$stdout = readLines(stdoutFile) retval$stderr = readLines(stderrFile) unlink(c(stdoutFile, stderrFile)) return(retval) } This will only work on a Unix-like shell that accepts > and 2> notations, and the cmd argument should not redirect output itself. But it does the trick: > robust.system("ls -la") $exitStatus [1] 0 $stdout [1] "total 160" [2] "drwxr-xr-x 14 asieira staff 476 10 Jun 18:18 ." [3] "drwxr-xr-x 12 asieira staff 408 9 Jun 20:13 .." [4] "-rw-r--r-- 1 asieira staff 6736 5 Jun 19:32 .Rapp.history" [5] "-rw-r--r-- 1 asieira staff 19109 11 Jun 20:44 .Rhistory" $stderr character(0)