Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4566958
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:51:45+00:00 2026-05-21T18:51:45+00:00

I am in a UNIX system administration course at school and have to generate

  • 0

I am in a UNIX system administration course at school and have to generate a Cron job that does the following:

  • Queries the system each hour to find
    out who is logged in.
  • Mails the result to my email account.

I know that the actual crontab will look like the following:

# Check to see who is logged in every hour.
MAILTO="me@email.com"
0       *       *       *       *       root    /tmp/loggedin.sh

OR

# Check to see who is logged in every hour.
MAILTO="me@email.com"
@hourly /tmp/loggedin.sh

But I have been Googling for some time and have been unable to find any examples of what exactly the .sh file should look like. I know it starts with:

#!/bin/bash
# Shell script to see who is logged in, to be run every hour.

And I have no idea what else to put in there. Any help is greatly appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T18:51:46+00:00Added an answer on May 21, 2026 at 6:51 pm

    I think who should do the trick. It will show you a list of all the users that are logged in to the system at a time. You can write this to a file and then have it mailed to you.

    w would get you what the people logged in are currently doing.

    So, the script would look like:

    #!/bin/sh  
    HOME=<your home directory>
    who > ${HOME}/usersLoggedIn.txt  
    w > ${HOME}/whatLoggedInUsersAreDoing.txt  
    

    ${HOME} refers to your home directory. On the command prompt, echo $HOME should give you your home directory. The output of the command who and w will get redirected to the files usersLoggedIn.txt and whattLoggedInUsersAreDoing.txt within your home directory. You can, of course, change the directory and file names to which you want this data to be written.

    HTH,
    Sriram

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file on a unix system. The following text file content
After reading the mkdir(2) man page for the Unix system call with that name,
I am looking for a client software that will run on a Unix system
I'm trying to comprehend the Unix file system on my OSX. I'm following wikipedia
On unix system when you call the accept system call, does the newly created
I have installed SQLite on my UNIX system, and am planning on accessing it
I have a multi-line ASCII string coming from some (Windows/UNIX/...) system. Now, I know
So, I am using C on a unix system and have access to the
I am doing some text processing on a unix system. I have access to
I have a binary file that was created on a unix machine. It's just

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.