---------- Post updated at 23:17 ---------- Previous update was at 23:09 ----------
Quote:
Originally Posted by eclip
2. Write a shell program to check once every five minutes if the system appears a process and attempt to kill him. Name of the process we give the command line.
Example usage:
$ Kill firefox
computer will be checked every five minutes, if any process running called Firefox, and will try to kill him. Hint: Be sure to use the kill command.
Code:
i have done something like this..
#!/bin/bash
while true
do
# in the next line Kill stands for this script name
ps -e | grep $1 | grep -v grep | grep -v Kill ##ps -e "see every process on system using standard syntax:"--
# this is not needed, see next line why a=$?
if [ $? -eq 0 ];then
kill `pidof $1` ## kill proces with pidof, wich was added like arg1
else
echo "this proces does not exsist"
fi
sleep 300
done
# this is not needed, since the stuff above is an infinite loop exit 1
# this is not needed, bcs. there is only one if statement fi
---------- Post updated 06-01-10 at 03:21 ---------- Previous update was 05-31-10 at 23:17 ----------
5.
Code:
#!/bin/sh
find $1 -type f -exec stat -f "%m%Sm %N" '{}' 2>/dev/null + | \
sort -nr | head -1 | \
sed 's/[0-9]*//;s/:[0-9 ]*\// \//;s/\([^/]*\)\(.*\)/\2 \1/'
Test run:
Code:
$ ./Findlatest.sh ~/code
/home/coder/code/sh/Findlatest.sh Jun 1 03:43
$ ./Findlatest.sh /usr/local/etc
/usr/local/etc/gimp/2.2/unitrc May 13 20:21
$
I'm not sure if this will work for you, since I tried it with a non-gnu version of stat.
Last edited by pseudocoder; 05-31-2010 at 10:54 PM..
Could someone tell me how I can simplify the script that follows!!!
I know that there must be a way how to
grep Average from sar01..................
sar02 .......................
sar03.......................
sar04... (3 Replies)
Hi guys! I have a dummy question for u :p
I cant find a solution for these tascks...tried everything (i know :cool: ).
1 Issue the following command sleep 1000
Note that sleep 1000 waits 1000 seconds!!! You cannot do anything now!!!
2 Open another terminal window and enter the tty... (1 Reply)
I've been given more responsibility at work and was basically told to take junior system admin responsibilities over our aix box. The catch is, I need to learn on my own. I know basics, but what are some task that I could perform on a daily basis for starters? We have a support group, but not so... (2 Replies)
1. Write a shell program which renames the current directory with the given file extension to another extension. The playoffs are given on the command line.
Example usage:
$ Rename txt doc
will be renamed:
aaa.txt in aaa.doc
Juhutxt in Juhudoc
...
* To solve, you can also help with... (5 Replies)
We have regularly questions about how to create users and user accounts. But regularly user accounts need to be deleted too. It is quite easy to delete the user account itself but usually the HOME directory of the user remains.
It is good style to remove these directories but simply deleting... (3 Replies)