.login or .profile to run crontab on login?

Hi,

Coming from a Windows background so no apologies for this question.

I'm trying to set up a login script to set up a job through crontab when I log in (not just when I open a terminal window)

My understanding is that .profile is where to put things that should run when you open a terminal session. However, i want my script to run when I login to OSX in the morning.

My script just sets up some aliases, so i can keep my firewire drives spinning without powering down throughout the working day, which is driving me nuts.

Script is:

alias spinoff="crontab -r"
alias spinon="crontab ~/Documents/spin_crontabs"
spinon

~/Documents/spin_crontabs just contains the crontab data.

If I put this in the .login file in my home directory, then the aliases don't show up in a terminal session, and the cron job doesn't show up in crontab -l

I know I'm 99% there, but I'm missing a vital clue!

Any help much appreciated.

Steve

iMac Nov 2007, Mac OS X (10.5.1), It's spelt - Aluminium

Posted on Dec 12, 2007 9:56 AM

Reply
4 replies

Dec 12, 2007 2:27 PM in response to stevesant

Post to the Unix forum under OS X Technologies. IIRC, you should use .bash_profile for you aliases, not .profile. Whether or not they'll work with crontab, I don't know, but do note that launchd now controls most startup processes, not cron. Check the manpages for those commands. Some people swear by Cronnix to manage cron jobs. See http://h775982.serverkompetenz.net:9080/abstracture_public/projects-en/cronnix/ for details.

Dec 13, 2007 2:27 AM in response to stevesant

I'm trying to set up a login script to set up a job through crontab when I log in (not just when I open a terminal window)


crontabs run at specified times. Turning them on and off is really ugly. cron has been demoted in Leopard, though it can be setup. The true login shell is masked by the login window. Login Items run applications at login. User shell config files only run in the Terminal. You might be able to muck around with the system shell config file(s) but I advise against it.

I'm trying to set up a login script to set up a job through crontab when I log in (not just when I open a terminal window)....f I put this in the .login file in my home directory, then the aliases don't show up in a terminal session, and the cron job doesn't show up in crontab -l


You need to read the bash manual. Look under the heading Invocation.

Dec 13, 2007 6:17 PM in response to Mark Jalbert

cron has been demoted in Leopard


Just to elaborate slightly, cron is deprecated in favour of the LaunchDaemon. On startup, the computer goes through /System/Library/LaunchDaemons and /Library/LaunchDaemons and executes them and/or puts them in the list of things to be executed on a schedule. You can also use launchctl to make sure a cron-like job starts and persists across reboots.

man launchctl and especially, for the format of the file to put in /Library/LaunchDaemons, man launchd.plist.

Or for something completely different, you could see http://docs.info.apple.com/article.html?artnum=301446 although that is also deprecated, if memory serves, though it sounds like it might be exactly what you are looking for.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

.login or .profile to run crontab on login?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.