LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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

Reply
 
Search this Thread
Old 10-03-2008, 08:33 PM   #1
duderancher
LQ Newbie
 
Registered: Oct 2005
Posts: 19

Rep: Reputation: 0
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?
 
Old 10-04-2008, 03:20 AM   #2
storkus
Member
 
Registered: Jun 2008
Posts: 310

Rep: Reputation: 45
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
 
Old 10-04-2008, 04:27 AM   #3
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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
 
Old 10-05-2008, 09:21 AM   #4
storkus
Member
 
Registered: Jun 2008
Posts: 310

Rep: Reputation: 45
Wow, looks like I learned something myself here--thanks!
 
Old 10-09-2008, 07:05 AM   #5
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,655

Rep: Reputation: Disabled
If this is a non-continuously running machine (workstation, desktop PC) you might be interested in fcron

http://fcron.free.fr/
 
Old 10-09-2008, 08:02 AM   #6
duderancher
LQ Newbie
 
Registered: Oct 2005
Posts: 19

Original Poster
Rep: Reputation: 0
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
 
Old 10-09-2008, 11:20 AM   #7
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 59
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.
 
Old 10-09-2008, 11:53 AM   #8
duderancher
LQ Newbie
 
Registered: Oct 2005
Posts: 19

Original Poster
Rep: Reputation: 0
That helps. Thanks.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron not working from crontab nor form /etc/cron/cron.d. What did SuSE change? JZL240I-U Suse/Novell 11 01-04-2007 01:57 AM
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM
crontab vs cron.daily ? SheldonPlankton Linux - Newbie 1 07-16-2004 12:10 PM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 02:30 PM


All times are GMT -5. The time now is 05:33 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration