Programming :: Process More Than 3 Hours Old From Shell Command?
Nov 14, 2010
My server pretty often becomes full up php processes running which are not needed. Is there a way to search for and kill any php process that is more than 3 hours old?
My server pretty often becomes full up php processes running which are not needed.Is there a way to search for and kill any php process that is more than 3 hours old? as I understand it, i need to use ps piped with awk. awk at the moment seems very complicated to me, do not how to start tackling it.
I have a shell script to identify whether the process is running or not. If the process is not running, then I execute another script file to run my application. Below is my script and saved this script as monitorprocess.sh Code: #!/bin/bash
I write a script to read a file which is something like a pipe (or) queue , which shows the running status.In normal case, if i open this file with cat command, i have to use ctrl+c to exit this . What command shall i use to do the same inside a shell script ? I have tried ^C in my script , but it does not exit the process.
I'm building a Linux From Scratch system and partially automating it. I will likely want to do it again, and I would like to try to almost completely automate it.
My current approach is a script that takes an input file and sequentially runs each line in a new instance of bash. If one fails, it gives me the number of the step that failed so that I can use the "--step" option to resume after I fixed the issue.
This has some problems: A varible created on one line will not be accessible on the next line. This is because each line is run in a separate shell (the reason for this is so that the commands in the input file and the script's internal variables can't interfere). You can't switch users or use chroot, again because each line is run in a separate shell.
What would be nice is to be able to start a bash process in the background and send commands to its stdin. I guess that a named pipe would work, but the named pipe will be gone after a chroot. Is there a way to do it without relying on the filesystem? Also, how do I know if the command failed?
I use tcl-expect script to ssh to the server. How can I eliminate the first 2 lines if using system(./script.sh) to execute it, as the default output will be shown on shell and the first 2 lines are included.
Essentially I just want to have the "ps" result, not the login process. code...
Is it possible to have an Expect script spawn an SSH session, log in, then go into interactive mode and give control of the SSH session to a Bash script? Here's a simplified example of the script so far:
Code: Select allapt-get install icedove-l10n-hu apt-get install rar apt-get install ... ... y press key or other language is other key. hungarian key is: i
english after apt-get install in gnome-terminal: (y)es or (n)o hungarian after apt-get install in gnome-terminal: (i)gen or (n)em
How to yes or no automatically in all languages? Not manual, not 'Y'/'I' or 'N'/'N' keydown.
I would like use this script my fresh installed Debian 7.1. I would like run this install.sh when Debian is installed for my all softwares when i would like use.
what we are trying to do is, to let the customer click a button in the web browser, and then the web server to call a shell script to do the work. The output from the stdout && stderr of the script should be displayed in the web browser once finished or timeout, along with the exit code of the script.
The shell script is however not on the web server, but on another app server. So to call this script from the web server as the identity 'tomcat':
Code: $ sh appuser@app-server:$appbin/app-script
The .ssh/id_rsa.pub thing is done, and we have no problem doing this in the command line so far.
Our loaded ex-colleage has left us the webpages (jsp) with code like these:
Code: <%@ include file="jsp_functions.jsp" %> <% String cmd = "sh $appbin/app-script"; ExecResult r = new ExecResult();
Why there is too much error in every version of gnome-shell and after everything slows down after a few hours of working in gnome-shell on debian(only on debian, i'm using gnome-shell in fedora and excellent experience i had in it) some of syslog output :
I am new to scripting and been working on this bash script for awhile now. I been researching this problem, but I can't seem to find a solution. I was wondering if someone could please help me out. Here is my script:
I cannot get this script to run the "ps -ef" command on the client. It get its value from the host machine that I am running this script from. I need this command to execute on the client. When I run the command (ps -ef | grep NO | grep -v grep) on the client, I get something back. Here is what I get when I try to debug the script.
This is weird. I have a shell script with no execute rights.$ chmod -x test.shThen I try$ test.shwhich does not work. (I have "." in PATH)When I do$ . test.shit works! I can run the script even though I have no execute rights. Why is that?Another question: If I have a shell script without a hash bang, I still can execute the shell script. Why? What does hash bang do? If there is no hash bang, why is the shell script run? What does the hash bang do
when I execute the command from the shell command line - it works and no error code.if I do the exact same command from a perl file - it fails with code 32512.the file is created from the same perl script that runs the command that fails. file permission is 0664.
How can we fire a shell command like ls,./a.out automatically in kernel space via a kernel module ? i.e. replacement of system() function of user space into kernel space.We need to develop a kernel module which can fire some shell command let say "firefox [url]" automatically to open google automatically from module.
If say, I want to read the input given by user at the command prompt and write a code to execute the cmd given then which commands do i use to implement this ( Im writing the code in C )?
Does anyone know a method of being able to process the complete and literal command line passed to a shell script ? I want to have the command line parameters with ALL characters (including meta characters e.g. $ literally).
So as if there was no shell to substitute or expand parameters nor applying it quoting rules.
I have written the following script in my linux server to add users for LDAP database.But i can't able to run this.
The script is as following
#!/bin/bash echo "Mention the username which you want to convert LDIF format" read username if ["$username" -e "/ldiffile/passwd"]; then echo "Username already exists" else cat /etc/passwd | grep -i "$username" >> /ldiffile/passwd fi The output which i got : . ldapadd.sh Mention the username which you want to convert LDIF format yal2361 -bash: [yal2361: command not found
I wonder if there is anyway to make a user-defined bash shell function global, meaning the function can be use in any bash shell scripts, interactively or not. This is what I attempted:
I am trying to fix a perl script, and I really suck at perl. But I think this problem will be easy for people who know it.
The problem is, I have an old setup script someone wrote many years ago. It fails if the standard shell is dash and not bash. The only way I've gotten it to work is to point /bin/sh to bash. I looked thru the script and it uses "system" many places, and I think that's the problem.
I searched for it and found this link:url
My plan is to include this function:
Code: sub system_bash { my @args = ( "bash", "-c", shift ); system(@args); } Then I could simply change all calls to system into system_bash and it should work?
The parameter to the system calls is usually some variable. What if the parameter is a list already? Do I need to test for it somehow, and if it's a list, prepend "bash" and "-c" to the list? How do I do that?
In the script there are lots of places like this:
my $error = system($cmd); if ($error) { die/warn "some error message"; }
Shouldn't there be a return in the system_bash function?
Trying to create a small script that will read user's input, test if user entered some input and if not display some message or display a text using user's input.
The script is the following but i get an error saying "[: 6: =: argument expected"
I am installling ubuntu on my old (2003) Dell D800 laptop with celeron processor, using a CD (burned at home). The installation process is hanging for about 24 hours now; it says "copying files..." with progress at 63%. The progress has not changed for about 10 hours.
I have a single hard drive on the machine (... noticed issues with dual drives on this forum, so thought I'd mention).
Joined the Linux community last week with a clean install of Ubuntu 9.10 and the Edubuntu overlay onto my wiped Dell Inspiron 8000 with 512MB RAM (max allowed) and nVidia GEForce2 GO video card. <<lspci: 00:00.0 Host bridge: Intel Corporation 82815 815 Chipset Host Bridge and Memory Controller Hub (rev 02)
I've some file with .sh extensions that runs some softwares.Now,how do I stop running that filesI know we run the command ./start_tomcat.sh to start the apache.Is there any command to stop that file/process or is it just kill the process to stop the process