Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Restrict certain applications to certain times of day System
I really need to keep working on my novel, but MacSolitaire is there in my dock, catching my eye and killing my productivity. I recently added this to my crontab, restricting my play to 6pm thru midnight:
######  Restrict time-killer applications
0 0-17 * * * chmod 000 /Applications/MacSolitaire
0 18-23 * * * chmod 644 /Applications/Macsolitaire
Of course this only works for applications owned by me and many are owned by root. However, you could use sudo chmod if you have turned off sudo passwords. For the line that turns the application back on, use the proper chmod to put it back like it was originally.

[robg adds: This is clearly an extreme example of enforcing self control, but it demonstrates a somewhat novel use for cron. There are a few hints here that discuss using cron, including a brief tutorial I wrote a couple years ago.]
    •    
  • Currently 2.50 / 5
  You rated: 4 / 5 (4 votes cast)
 
[6,610 views]  

Restrict certain applications to certain times of day | 6 comments | Create New Account
Click here to return to the 'Restrict certain applications to certain times of day' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
For root-owned stuff, use the system crontab
Authored by: grrl_geek on Jul 10, '03 11:34:52AM

You can always add a line to /etc/crontab/, which will then run as root. You have to restart the computer or cron afterwards, I believe. Beware of typing mistakes while running as root. You may have a unscheduled scheduled reinstall! :)

If you don't have to run as root, then the personal crontab is a much better and less dangerous way to go.

---
~~~~~~~~~~~~~
Sinker sucker socks pants, apocryphal awry!



[ Reply to This | # ]
For root-owned stuff, use the system crontab
Authored by: googoo on Jul 10, '03 01:17:21PM

You do not have to restart anything after modifying /etc/crontab. The cron process reads the /etc/crontab file (along with the various user crontab files) each minute to see if anything needs to run. For more information, check out the cron and crontab man pages.

-Mark



[ Reply to This | # ]
Thanks
Authored by: grrl_geek on Jul 10, '03 08:09:44PM

Cool, thanks for the info, Mark.

Rachel

---
~~~~~~~~~~~~~
Sinker sucker socks pants, apocryphal awry!



[ Reply to This | # ]
Doesn't work as desired
Authored by: eaganj on Jul 10, '03 11:44:26AM

You don't really want to change the permissions every hour (unless you don't trust yourself to run around behind the cronjob and change the permissions manually -- in which case this cronjob is useless).

Just set the cronjob to run at the borders. In your example, disable permissions at midnight and re-enable at 6pm:

0 0 * * * chmod 000 /Applications/MacSolitaire
0 18 * * * chmod 644 /Applications/Macsolitaire



[ Reply to This | # ]
Doesn't work as desired
Authored by: hmelton on Jul 10, '03 01:51:05PM

I set the cron up as you suggested at first, but since I am using a laptop that frequently is turned off, I decided to reset the permissions hourly to avoid having the application available or not available at unexpected times. The trick here is to train my brain. Computers can afford to be inefficient.



[ Reply to This | # ]
Doesn't work as desired
Authored by: readparse on Jul 10, '03 07:16:14PM

<jab type=easy>
If your brain was trained we wouldn't be talking about this.
</jab>



[ Reply to This | # ]