|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
|||
|
|||
|
Hello. Bare with me, I am still learning UNIX. So, you may laugh at the simplicity of my questions.
I'd like to know a few things that I have not been able to find online. I may have just not found the right spot yet. But, a lot of my searching ends up in forums. So, I thought I might as well just start a thread. I have been fooling around with crontab. It seems very simple according to the man pages; however, one of my entries will not work. I know I have the 5 entries for the duration the command is executed set correctly...and I know I haven't fat-fingered anything else. I see in the log file (/var/adm/cron/log) that an attempt is made to execute the command. I was told some of the characters on the line in the log could point to an answer. But, I am unable to decrpyt anything. I have the entry set to run a script I built, which runs when I manually type it. Also, I have another entry in the crontab file - that works - to run another script I built. Each script is set to run at a different time, so I don't think there would be any conflicts. I am not sure why cron will not complete it. Any advice is appreciated! ...now you can laugh |
|
#2
|
||||
|
||||
|
It's hard to pinpoint the problem without seeing the log. However, one of the things to bear in mind is that the cron jobs run under a different environment than your regular login. In particular, cron doesn't have the same PATH variable as your login, hence you should specify all pathnames as absolute path names, to be safe. This is the #1 cause of errors in cronjobs.
For example, if you wanted to print a list of files, you could simply type "ls" and get a list. This is because your PATH variable has "/bin" in it and so the shell can find it. With a cron job, you may need to type "/bin/ls" so that it can find the program.
__________________
Up the Irons What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home. "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest Down with Sharon Osbourne Puzzle of the Month solved by sizeablegrin, etienne141 and L7Sqr, superior C/C++ programmers of the month |
|
#3
|
|||
|
|||
|
Here is the line from crontab -l
30 * * * * /d2/www/offline_prob/g_offline My script only has two commands and I am redirecting the output to another file. I'm still working with the script, so there will be more entries for it; however, I'd like to go ahead and use cron to automate it. BUT...problems... I didn't know about the PATH variable and cron...thanks for the info. |
|
#4
|
|||
|
|||
|
as scorpion said, cron has a very limited ENVIRON, not only PATH but all other
variables set by the login-session are missed. q1: witch shell are you using q2: witch shell is cron using you have different way to fix that: - scorpion's suggestion: use full qualified names NOT only for cron but also for the script running penalty: you loose flexibility in the script. - set the envs using 'env' eg: * * * * * /bin/env XXX=xxx YYY=yyy /your-command now cron (/your-command) knows the values of $XXX and $YYY penalty: for each changes you have to reedit cronttab ![]() - FORCE cron to process your $HOME/dotfiles eg: * * * * * . $HOME/.profile ; /your-command ![]() note the dot before dollar - FORCE the script to process your $HOME/dotfiles (my preferred way) eg: * * * * * /your-command (assumed you use /bin/sh) and in /your-command is: #!/bin/sh . $HOME/.profile # again, note the dot at begin ..... the rest of code no penalty, the code will run ![]() ps: the only values known by cron are the entries in /etc/passwd for that user and (like scorpion said) a minimal PATH, nevertheless i expect '/bin' in it. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > Crontab |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|