Cron Job

There are 17 replies in this Thread which was already clicked 836 times. The last Post () by davvo.

  • Hi guys


    have setup Ubuntu on pc with OSCam r11164 all up and running have installed webmin so my questions are i would like Ubuntu pc to reboot at 6am everyday and a script to keep checking oscam is running and stop/restart when needed etc also use LogCleanup once a week now this is all new to me so sorry for all the questions could someone please advise as to what I need to put where in order for theres to work. as far as I can tell all file are installed just need to edit them




    thanks for your time


    - - - Updated - - -


    could anyone please tell me what I have to input in here

  • Hope this explains it a bit clearer


    0/30 * * * * root /var/script/oscam-checker.sh >/dev/null (runs oscam-checker script (at 30 sec intervals i think but not 100% sure)
    59 23 * * 5 root /var/script/Logcleanup.sh (runs logcleanup script at 11:59pm on fridays only)
    59 23 * * * root /var/script/oscam-backup-sh (runs oscam backup script at 11:59 pm daily)
    00 6 * * * root /sbin/reboot (reboots server at 6:00am daily)
    01 04 * * * root/var/local/bin/oscam-update.sh (runs the oscam-update script at 01:04am daily)

    Adjust the entries to suit your needs.


    Here is a good explanation of exactly what the fields represent:
    http://linuxsat-support.com/showthread.php?t=14263



  • who put all the times in the crontab
    as in your screenshot post 1




    56 = minutes
    03 = hours
    5 = checks if oscam is running every 5 mins
    03 04 * * 6 = deletes the logs at 4.03am every 6 days
    change cam names and times to suite
    check spellings to match scripts
    and cam


    if you write a crontab with the wrong spelling
    of the script that its looking for it wont work


    /etc/crontab



    Code
    56 03 * * * root killall oscam
    57 03 * * * root /var/script/configupdate.sh >> /var/oscamlog/configupdate.log
    59 03 * * * root /usr/local/bin/oscam -b
    */5 * * * * root /var/script/OscamCheck.sh
    03 04 * * 6 root /var/script/LogCleanUp.sh >> /var/oscamlog/CleanUp.log



    OscamCheck.sh

    Bash
    #!/bin/sh 
    process=`ps auxwww | grep oscam | grep -v grep | awk '{print $1}'`
    if [ -z '$process' ]; then
    echo "Couldn't find Oscam running. Restarting server-binary" >> /var/cccamlog/oscam.check 
    echo && date >>/var/cccamlog/oscam.check
    /usr/local/bin/oscam >> /var/cccamlog/Oscam.log & 
    else echo "Oscam is still OK!" >> /var/cccamlog/oscam.check 
    fi

    Edited 7 times, last by davvo ().

  • you can run any script manually from the terminal


    just type the path to the script


    example
    if in /var/script
    you had
    LogCleanUp.sh


    type
    sudo -i


    type your
    password


    now your root


    then type


    /var/script/LogCleanUp.sh

  • do you have a file in /var/script


    called


    LogCleanUp.sh


    if you have
    then in that file
    it will look in
    TARGETDIR_1=/tmp
    TARGETDIR_2=/var/cccamlog


    for these


    FILE_1=warning.txt
    FILE_2=cccam.check
    FILE_3=oscam.check
    FILE_4=CCcam.log
    FILE_5=Oscam.log


    and if there is nothing there it cant remove it


    open LogCleanUp.sh
    and have a look
    for the paths and files names

    Edited 3 times, last by davvo ().

  • do you have ubuntu server
    or ubuntu desktop


    easier to use ubuntu desktop
    so you can see what your doing


    ubuntu server mate I can see what I'm doing just don't know what i'm doing :nocomment:


    think I should start from scratch what is the best way to do that do you think would I have to reinstall everything

  • then there is no warnings


    so now you need to open your
    LogCleanUp.sh file


    look at the TARGETDIR paths
    then under that the files names


    if in the TARGETDIR there is no files
    by them names
    then it cant delete them


    you can test by making a file
    example


    to make a file called Oscam.log
    in /var/Oscamlog


    type


    touch /var/Oscamlog/Oscam.log


    now run
    LogCleanUp.sh
    to clean it


    only do it with the files names you have in your LogCleanUp.sh
    so it can do it

    Edited 2 times, last by davvo ().

  • Looks like you cut and pasted too much for the logcleanup script. You need to remove the top lines:

    Code
    #############################################
    scriptname = LogCleanup.sh
    #############################################
  • this is my LogCleanup.sh


    do I have to put any info in it also do I need any info in my config.file



    what does this mean
    Output from command /var/script/pcscd_check.sh ..
    No output generated



    OWNER=ste
    TARGETDIR_1=/tmp
    TARGETDIR_2=/var/Oscamlog
    FILE_1=warnings.txt
    FILE_2=Oscam.check
    FILE_3=Oscam.log
    FILE_4=configupdate.log


    echo && date


    if test -f $TARGETDIR_1/$FILE_1 ; then
    echo "warning text present!"
    chown $OWNER $TARGETDIR_1/$FILE_1
    rm $TARGETDIR_1/$FILE_1
    else
    echo "No warning text present?!?!Nothing to remove"
    fi


    if test -f $TARGETDIR_2/$FILE_2 ; then
    echo "Check File present!"
    chown $OWNER $TARGETDIR_2/$FILE_2
    rm $TARGETDIR_2/$FILE_2
    else
    echo "No Check File present?!?! Nothing to remove"
    fi

    if test -f $TARGETDIR_2/$FILE_3 ; then
    echo "Oscam Debug Log precent!"
    chown $OWNER $TARGETDIR_2/$FILE_3
    rm $TARGETDIR_2/$FILE_3
    else
    echo "No! Oscam Debug log present, Oscam did run perfect !!"
    fi


    if test -f $TARGETDIR_2/$FILE_4 ; then
    echo "Check File present!"
    chown $OWNER $TARGETDIR_2/$FILE_4
    rm $TARGETDIR_2/$FILE_4
    else
    echo "No Configupdate log present?!?! Nothing to remove"

    fi
    exit

    Edited 4 times, last by ste211270 ().

  • when you run LogCleanup.sh
    it checks if those files
    below are there
    it looks in /tmp
    and /var/Oscamlog
    if those files are not present it cant remove them





    OWNER=ste
    TARGETDIR_1=/tmp
    TARGETDIR_2=/var/Oscamlog
    FILE_1=warnings.txt
    FILE_2=Oscam.check
    FILE_3=Oscam.log
    FILE_4=configupdate.log


    why do want to clean logs that are not there

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!