I am now reading the source code of try_to_wake_up() function of Linux Kernel. This function does a lot and includes this: return p->on_rq == TASK_ON_RQ_QUEUED. So, what is the actually purpose of on_rq field in task_struct. BTW, does there exist some manuals or reading materials to introduce all the field…
Running awk command in remote host fails
I am running a shell script to run awk command on a remote host. The awk command runs fine locally, but when run for the remote host fails (the redirected file is empty): Here is the script run on remote host: smb.conf.tmp is empty in remote host !! Locally: I followed this link for awk running on remote host…
Expanding shell variable in sed in remote host
The sed command, which is run locally looks like this (it works fine): However, if i try t run the same in a remote host doing an ssh, it gives me issue: What am i missing here? Answer Variable Expansion The problem you’re encountering has to do with shell expansion in strings. There are two relevant ca…
Extra backslash when storing grep in a value
In a bash script I have: When you run it it shows it as: Now it works exactly what I want but I want to understand it. Why is there 2 extra ‘s? Answer The output from set -x uses single quotes. So the outer double quotes were replaced with single quotes but you can’t escape single quotes inside a
Why linux split program have weird behavior with large files >20GB?
I’m doing the next statement on my ubuntu: If i do a “ls” If i do a “du” over ab and ad files. As you can see, split divided the file in a non-homogeneous form. Anyone know what’s going on? Some unprintable character can hang the split? Thank you. Best Regards! Francisco. A…
shell script to kill tomcat service if it is not stopped by stop command after certain amount of time?
I would like to write shell script to start and stop tomcat server.For stopping the tomcat I am using this command “./bin/shudown.sh” or “./bin/catalina.sh stop”. This is not working most of the times, tomcat is still running.So I would like to kill the tomcat after giving shutdown com…
How to append entry the end of a multi-line entry using any of stream editors like sed or awk
I am trying to use a script to append the host name at the end of a multi-line entry of a specific Host_Alias field in sudoers file. The current sudoers file has an entry similar to : My required output would be something like the following where I have added “,host25” There are more lines before …
django settings.py os.environ.get(“X”) not fetching correct values
I am trying to access and fetch (get) value of OS Environment variable into settings.py and while debugging application I get None value for that record. Here are more details: There are some important/secret keys which can’t be shared in code so those are exported in OS environment variables. Whenever …
auditing opened/closed ports on Linux
Is there an auditing tool to check which and when ports are opened and closed on Linux? My goal is to run my application and check its ports usage. lsof or netstat don’t fit because they just tell me which ports are currently opened, and looping on such command won’t give me accurate results……
Extract lines from File2 already found File1
Using linux commandline, i need to output the lines from text file2 that are already found in file1. File1: File2: Output: Thanks! Answer A more flexible tool to use would be awk Example What it does? NR==FNR{lines[$0]++; next} NR==FNR checks if the file number of records is equal to the overall number of rec…