I have written a simple bash script that I want to use as a time clock for employees (work-studies) in my computer lab. The script works great.
1. Each work-study has two icons (two separate bash scripts) on their desktop, one to clock in and another to clock out. They both write to the same .txt file.
2. When they click the clock-in icon, the script writes CLOCK IN and the current date and time to a plain text file in a shared Dropbox folder (shared between me and the work-study computer).
3. The script pauses for five seconds so the .txt file can update on Dropbox.
4. The browser opens with the work-study's updated time clock log. This is done via a Dropbox share link.

Here is the script for clocking in. The clock out script only says CLOCK OUT instead.

# Write to .txt file
echo " CLOCK IN - $(date '+%x - %r')"  >> /Users/Username/Dropbox/Joe-Time-Clock.txt 
# Give Dropbox a chance to sync.
sleep 5
# Open in browser so student can see clock in time.
open -a Google\ Chrome "https://www.dropbox.com/s/7vbgpc9x29d0z98/Time-Clock.txt?dl=0"
exit 0

Here is the plain text output:

Joe Smith - Time Clock
 CLOCK IN - 08/17/2015 - 06:00:25 PM
CLOCK OUT - 08/17/2015 - 06:00:48 PM
 CLOCK IN - 08/17/2015 - 06:00:52 PM
CLOCK OUT - 08/17/2015 - 06:05:14 PM
 CLOCK IN - 08/17/2015 - 06:14:51 PM
CLOCK OUT - 08/17/2015 - 06:15:11 PM

As of now, the student can simply open Joe-Time-Clock.txt when they are late and change the information. The work-studies are on a regular account on the Mac (10.6 Snow Leopard), and I have an admin account to which they do not have access. I would like for them to be able to execute the script on the desktop that writes to their time-clock file. However, I do not want them to be able to edit the script or edit the clock-in / clock-out log (Joe-Time-Clock.txt).

I fiddled with the permissions today. If Joe-Time-Clock.txt is synced by Dropbox and has root ownership enabled, then Dropbox, being a per user application, would not be able to sync it because it would lack the permissions. Otherwise, I would try this solution. Any ideas are welcome. Much thanks in advance.

Side note: I am much more used to working with permissions and command line in Linux. Today, when I spent a bit of time on CLI in OS X it felt a bit foreign, so the more details the better. Thanks!

  • Use a LoginHook and LogoutHook to record the time and a user's LaunchAgent to open the browser. Link- developer.apple.com/library/mac/documentation/MacOSX/Conceptual/…
    – fd0
    Aug 19, 2015 at 13:00
  • @fd0 I ended up using a web form instead to do the same thing, only it also includes the client IP address to make sure there is no clock in from a different location than in the office. Thanks for the idea though.
    – jbrock
    Aug 22, 2015 at 1:14


You must log in to answer this question.

Browse other questions tagged .