I’am using a EC2 instance to run a large job that I estimate to take approx 24 hours to complete. I get the same issue described here ssh broken pipe ec2 I followed the suggestion/solutions in the above post and in my ssh session shell I launched my python program by the following command: Once I did th…
Tag: unix
What should the “share” subdirectory contain?
When one has installed a library and look at what its repository contain, he may find something like that: repo/ bin/ lib/ share/ What the “share” repository should contain in general? Are there other types of subdirectories? Thanks! Answer The “share” word is used because what is unde…
Export value of corresponding site out to a new text file
I have a text file that contains two columns of data, the first column being a site ID and the second being a value. If the value is equal to 0, I want to send the corresponding site ID out to a new file. If the value is equal to 15, I want to do nothing. Text File: Attempted Script:
what does -d value in an if expression in shell?
I am trying to understand a part of search function written in a piece of code below is the expression mentioned. Answer You can use it to determine if a directory exist like
Measuring execution time with clock in sec in C not working
I’m trying to measure execution time in C using clock() under linux using the following: The output is: The documentation says to divide the clock time by CLOCKS_PER_SEC to get the execution time in sec, but this seems pretty incorrect for a 2sec sleep. What’s the problem? Answer Sleeping takes al…
Cronjob script isn’t working as expected
I have a script that work perfectly fine when I manually run it by myself, but does not seem to run properly from crontab. The main error is that the (external) environment variables are not being set. I added SHELL=/bin/bash above the cronjob definition but still got the same errors. The script I have copied…
ls to list matches in specified directory
How do I list matched results in a specified directory? On my Ubuntu server if I list the contents of a directory it correctly lists it. My working directory is /var/crash. Let’s say I want to list all files that contain ‘tar’. In this example there should only be one match i.e. start.txt Al…
Shell: How to move multiple files to a directory and zip that directory with different name?
Fore example, I have some files in my project, structure could be like this I want to zip some files from my project and I can do that using ZIP command (build folder and some other files are excluded from zip) After this new file is created: In Mac Finder when I double click on this file it becomes unzipped
replace text between two tabs – sed
I have the following input files: and I am trying to find the second string between the two tabs (e.g. text2, abc2) and replace it with another word. I have tried with but it only deletes the tab and does not replace the word. I appreciate any help! Answer I would suggest using awk here: Set the input and out…
sleep 0 has special meaning?
I’m seeing a lot of usages of sleep 0 in my one of my client project. The code look something like this. Reading through some of the answer of SO like this it seems that sleep 0 has some significance. What I want to known now is that does scheduling for other thread to run (if they are waiting to