linux - cron job monitoring script

07
2014-07
  • vikas24_pandey

    greeting of the day!!! please help me a situation, i am trying to develop a script which provides me details which my cron job is commented or stopped which job is running or scheduled. like we there is number of scripts which is scheduled or some of them are stopped and we need to check it manually, want to check which job is stopped by "#" along with name and running job with job name.

    i have tried with transfer cron to a file and grep line index those starting from "#". i have their index no, but now unable to do further loop or check, i tried but it goes inside all commented job. trying something like this

    for line in $(grep -n "#" cronfileTest) do awk'{ if($i==$line) then echo "commented"$i break;
    }'

    done

    please help me in this situation and kindly ignore all grammatical and syntax error as i'm new bee. please help me

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    linux - Screenshot cron job not working
  • Vilhelm Frändberg

    I've been searching all over the internet for an aswer to this but can't seem to find anything that works for me.

    I want to run a cron job that automaticly takes a screenshot every minute. The script look like this:

    #!/bin/bash
    cd /home/ville/Skrivbord/screenshot
    import -display :0 -win root screenshot.jpg
    

    The code works fine when manually executed but does not work when i run it as a cron job.

    The cron file look like this:

    * * * * * /root/bin/screen.bash &> /dev/null
    * * * * * /root/bin/syncdata.bash
    

    The other task, syncdata works fine.

    Here are some of the things i've tried without success:

    Change permissions on /root/bin/screen.bash and /home/ville/Skrivbord/screenshot to 777 and change owner to root.

    Change filename to screen.sh (maybe there's no difference between .bash and .sh?)

    Change the import line to "import -win root screenshot.jpg" and "import -display :0.0 -win root screenshot.jpg".

    Added the code:

    # Set display to :0 if it's not already set.
    : ${DISPLAY:=:0}
    export DISPLAY
    

    One time above the existing code in screen.bash and one time below.

    Changed the line in cron to "* * * * * export DISPLAY=:0 && /root/bin/screen.bash".

    Nothing works!

    Please help me


  • Related Answers
  • grawity

    Programs started by the cron daemon do not have the authentication data needed to connect to your X server. Try putting something like this in your ~/.xprofile:

    if [ "$XAUTHORITY" ]; then
        cp -f "$XAUTHORITY" ~/.Xauthority
    fi