Close

Results 1 to 8 of 8
  1. #1
    DF VIP Member eblaster101's Avatar
    Join Date
    Aug 2003
    Location
    London
    Posts
    2,827
    Thanks
    142
    Thanked:        121
    Karma Level
    420

    Default Unix help urgent help please!

    hi,

    i really really need help with some work i need to do really stuck in the mud here any help will be appreciated.

    I have been asked to create a script which performs a action only when nobody is using the computer.

    if you know how to do this can you please explain will be greatlly appreciated.

    thanks


  2. #2
    DF VIP Member /dev/null's Avatar
    Join Date
    Feb 2004
    Location
    Behind You
    Posts
    2,952
    Thanks
    0
    Thanked:        0
    Karma Level
    451

    Default Re: Unix help urgent help please!

    Try cron...?

  3. #3
    DF MaSter petecowie's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    96
    Thanks
    0
    Thanked:        0
    Karma Level
    281

    Default Re: Unix help urgent help please!

    BTW: cron allows you to schedule jobs to run on a particular day, hour, minute, day, etc.
    So set the program to run at a time you can guarantee no-one is on the system for example 3am, this way your script doesn't have to perform this check itself. Log in as root and type the command crontab -e this will allow you to edit roots cron (schedule) Just add another line to represent the program you want run. The five numbers on the line tell you cron when to run and represent minutes hours monthday month weekday and are following by command to run ls -l to a file at 5am everyday use the following
    0 5 * * * ls -l > /tmp/filename

    Hope this helps (and that I've got it right, it's been a while!)

    Pete

  4. #4
    DF VIP Member ShadowMoses's Avatar
    Join Date
    Oct 2003
    Location
    Wales, UK
    Posts
    1,168
    Thanks
    0
    Thanked:        0
    Karma Level
    309

    Default Re: Unix help urgent help please!

    as far as crontab entry's go I found this tool

    http://htmlbasix.com/crontab.shtml

    you put in what script and when you want it running and it generates the line you need to add to the crontab

    not too sure how to get it to check and only run when others are online.

    hope I helped in some way

    Moses

  5. #5
    DF VIP Member BertRoot's Avatar
    Join Date
    Sep 2004
    Location
    Poppy Fields
    Posts
    23,955
    Thanks
    1,038
    Thanked:        2,059
    Karma Level
    2513

    Default Re: Unix help urgent help please!

    What sort of computer? A UNIX server? A UNIX workstation? Cron would not be suitable for this sort of thing IMO? Can you clarify your requirement?


  6. #6
    DF VIP Member eblaster101's Avatar
    Join Date
    Aug 2003
    Location
    London
    Posts
    2,827
    Thanks
    142
    Thanked:        121
    Karma Level
    420

    Default Re: Unix help urgent help please!

    its a unix workstation mate

    the computer has to chek when no one is on the server because its running on a unix server, which is being accessed all the time at random times. I think i have to use the command 'who' becasue who checks who is logged into unix
    Last edited by eblaster101; 30th March 2005 at 12:31 PM. Reason: more info

  7. #7
    DF VIP Member /dev/null's Avatar
    Join Date
    Feb 2004
    Location
    Behind You
    Posts
    2,952
    Thanks
    0
    Thanked:        0
    Karma Level
    451

    Default Re: Unix help urgent help please!

    Well, lets say you were using the root account to run the script (or you have created a special account to do it) then you would have something like this:

    Code:
    #!/bin/bash
    if who | grep -v "root" != ''
    then
    echo Cannot run script - other users logged in
    exit 1
    fi
    
    #the rest of your script here
    That is assuming the script can be initiated wen someone else is logged in, but if they are then it will not run fully, it will see that they are logged in and then terminate until the next time it is scheduled to run. You could even have it run say every 15 minutes, each time it would fail if there was someone logged in and then when it sees that no-one apart from root or your created account is logged in, it will run the script.
    Hope tihs helps a little - you may get a bit better help in the linux section though because more unix users will look in there.

  8. #8
    DF VIP Member eblaster101's Avatar
    Join Date
    Aug 2003
    Location
    London
    Posts
    2,827
    Thanks
    142
    Thanked:        121
    Karma Level
    420

    Default Re: Unix help urgent help please!

    hey thanks for your help guys can a mod please move to linux section please

Similar Threads

  1. URGENT weird problem i can't solve
    By PimpMasterT in forum PC Problems
    Replies: 4
    Last Post: 21st October 2002, 03:02 PM
  2. URGENT weird problem i can't solve
    By PimpMasterT in forum Microsoft Windows XP & Vista
    Replies: 0
    Last Post: 19th October 2002, 03:34 PM
  3. urgent help please
    By gingertosser in forum PC Problems
    Replies: 3
    Last Post: 10th September 2002, 05:08 PM

Social Networking Bookmarks

Posting Permissions

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