Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-03-2008, 08:33 PM
|
#1
|
|
LQ Newbie
Registered: Oct 2005
Posts: 19
Rep:
|
help me understand the difference between cron.daily and crontab -e
I am running into some inconsistent behavior when testing and then running cron jobs.
If I run a cron job using the "crontab -e" edit, my shell is /bin/sh
If I run the same cron job using the cron.daily (in RHES4), my shell is /bin/bash
Why? And more importantly, can I make the "crontab -e" method use bash instead of sh?
|
|
|
|
10-04-2008, 03:20 AM
|
#2
|
|
Member
Registered: Jun 2008
Posts: 288
Rep:
|
Umm, on every Linux distro I know of, /bin/sh is linked to /bin/bash, so there shouldn't be any difference. The only possible catch may be with Slackware (which I run) which, for a few things (I think primarily during installation, though) uses the "ash" shell, a stripped-down shell that provides VERY basic functionality in exchange for a teeny-weeny roughly 63kB size.
Mike
|
|
|
|
10-04-2008, 04:27 AM
|
#3
|
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
There is a behavioral difference between /bin/sh and /bin/bash. When called as /bin/sh, bash acts in a more /bin/sh compatible mode.
cron.daily is a bash shell script called another crontab entry, thus the different shells.
cron uses sh; if you want a cron job to use a different shell, add the #!/bin/bash interpret line to the shell script file the cron job calls. Eg:
Code:
$ crontab -l
#minute hour mday month wday command
58 */2 * * * /home/mrc/bin/dobackups
$ head -4 ~mrc/bin/dobackups
#!/bin/bash
PATH=/usr/local/bin:/bin:/usr/bin:/usr/sbin
export PATH
|
|
|
|
10-05-2008, 09:21 AM
|
#4
|
|
Member
Registered: Jun 2008
Posts: 288
Rep:
|
Wow, looks like I learned something myself here--thanks!
|
|
|
|
10-09-2008, 07:05 AM
|
#5
|
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 12.3_64-KDE, Ubuntu 12.04, Fedora 17, Mint 14, Chakra
Posts: 3,522
Rep: 
|
If this is a non-continuously running machine (workstation, desktop PC) you might be interested in fcron
http://fcron.free.fr/
|
|
|
|
10-09-2008, 08:02 AM
|
#6
|
|
LQ Newbie
Registered: Oct 2005
Posts: 19
Original Poster
Rep:
|
Mr C.
I have the #!/bin/bash statement as the first line in the script although I am not sure it solves that problem. Withing the script, I use the "env" command (and sent he output to mail) to check the environmental variables in the script shell. I get the following:
SHELL=/bin/sh
OLDPWD=/root
USER=root
PATH=/usr/bin:/bin
PWD=/data/data_processing/samples
HOME=/root
SHLVL=2
LOGNAME=root
_=/usr/bin/env
I would expect to see the shell = /bin/bash . I don't get it.
JZL,
Thanks for the tip. I will make use of the cron.daily scripts before I try your suggestion but it is good to know I have options.
Thanks
Dan
|
|
|
|
10-09-2008, 11:20 AM
|
#7
|
|
Senior Member
Registered: Jun 2008
Posts: 2,529
Rep:
|
The SHELL variable indicates a user's preferred shell for launching applications by other applications when they call upon a shell to perform work. It does not override the interpreter line at the top of an executable file. This is often confusing to new users, as they expect SHELL to match the name of their current shell.
|
|
|
|
10-09-2008, 11:53 AM
|
#8
|
|
LQ Newbie
Registered: Oct 2005
Posts: 19
Original Poster
Rep:
|
That helps. Thanks.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:52 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|