Hy i have some tasks to do in school but i'm having problems with it,so could you help me out?
first there is a task where i have to find a running program on the system and kill it, then repeat that every 5 minutes. The name of the process is given with an argument. I have done this so far, but still not working.
if $1 in $(ps -e) ; then
kill $(pidof $1)
sleep 5m
fi
then i have to write a program which can tell me how many processes is running by some user, from the /etc/passwd file
it should look like this:
root 50
me 55
other 2
with this i just get the sum of all processes
user=$(cut -d: -f1 /etc/passwd)
process=$(( pgrep -cu $user))
echo -e "$user"
and the final one is where i have to search all files in given directory and it's subdirectories and it should give me a file wich was last changed(used)
the argument of the program should be like for example: /usr/etc
and the output would be: /usr/etc/httpd/httpd Oct 25 12:16
Please give me some good pointers, i'll appreciate it very much THANKS !