Viewing 1 to 11 of 11 items
Tag Archives: Grep

display how many files that user accessed

All of these commands can be used inside of your scripts and can make for a very powerful toolset for developing programs in unix. For an example of using these commands in a script, let’s write a script that uses our current data file. The script will get all users that are in the file  Full Article…

0

This script checks the log file for timeouts

Code: #!/bin/ksh ################################################################################################## # # This script checks the log file for timeouts # ################################################################################################## TIMEOUT=`tail -5000 /dir1/logs/logfile.log | grep “has timed out and is not currently tradeable” | tail -1`; echo ${TIMEOUT}; if [ ! -z ${TIMEOUT} ]; then echo “Timeout Alert”; else echo “No Timeouts”; ———— TIMEOUT=`tail -5000 /dir1/logs/logfile.log | grep “has timed  Full Article…

0

Check if program is running with bash shell script?

This is an example of a bash script which checks for some running process (daemon or service) and does specific actions (reload, sends mail) if there is no such process running. check_process(){ # check the args if [ “$1” = “” ]; then return 0 fi #PROCESS_NUM => get the process number regarding the given  Full Article…

0

Linux: Kill Process based on Start Time (STIME)

One of the server that I am working with has some infinitely running PHP process. Due to incorrect way of cron setup by the development team, it has caused the process hanging and not ended properly. According to them, these processes can be killed if still hang after 12 hours. Any process which run in server will  Full Article…

0

Excluding grep from process list

ps aux | grep daemon_name | awk “{ print $2 }” grep’s -v switch reverses the result, excluding it from the queue. So make it like: ps aux | grep daemon_name | grep -v grep | awk “{ print $2 }” Upd. You can also use -C switch to specify command name like so: ps -C daemon_name -o pid=  Full Article…

0

lsof to find the process

lsof -t -i:4444 would list only the pid of the process listening on port 4444. You could just say kill `lsof -t -i:4444`   You use lsof: # lsof -n | grep TCP | grep LISTEN | grep 4444 The output will be something like: pname 16125 user 28u IPv6 4835296 TCP *:4444 (LISTEN) Where the  Full Article…

0