Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2009
    Posts
    245

    Need simple bash script

    I need script which will load every minute and which will log to file if command ps -ef finds executing command perl.Would be that possible?

  2. #2
    Join Date
    Oct 2006
    Location
    /usr/src/linux/
    Posts
    699
    Code:
    check=`ps -ef | grep perl | awk '{print $8}'`
    if [ "$check" = "perl" ]
    then
            echo "perl pid found" >> /var/log/perl_check
    fi
    exit
    Should do the trick
    VPSnoc.com offers high quality Xen OpenVZ & Windows Virtual Private Servers at affordable prices.
    99.95% Uptime | 24/7/365 Support | Unmetered bandwidth.
    Follow us: twitter.com/VPSnoc

  3. #3
    Join Date
    Jun 2008
    Location
    India
    Posts
    129
    put that script in a file and run it in a cron tab. If you would like then you can modify script little more to get what all are the process running it..

    #! /bin/bash
    check=`ps -ef | grep perl | awk '{print $8}'`
    if [ "$check" = "perl" ]
    then
    echo "perl pid found" >> /var/log/perl_check
    ps aux | grep perl >> /var/log/perl_check
    echo "*************************************" >> /var/log/perl_check

    fi
    exit

Similar Threads

  1. Can .htaccess call a script (e.g. a bash .sh script)?
    By Kadence in forum Hosting Security and Technology
    Replies: 7
    Last Post: 03-26-2008, 03:59 PM
  2. simple bash script needed !
    By learnerman in forum Hosting Security and Technology
    Replies: 3
    Last Post: 09-24-2007, 11:16 PM
  3. Simple Bash...
    By camers in forum Programming Discussion
    Replies: 6
    Last Post: 07-09-2006, 08:57 PM
  4. Easy Weekend Cash - Needed: Simple Unix Bash Script
    By yugnats in forum Employment / Job Offers
    Replies: 9
    Last Post: 03-30-2006, 04:26 PM
  5. bash comman/bash script
    By getbusy in forum Hosting Security and Technology
    Replies: 2
    Last Post: 12-25-2004, 06:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •