cron can't find bash


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cron can't find bash
# 1  
Old 06-21-2012
cron can't find bash

Hi,

I'm running OS 10.3.9 and am trying to get a cron job to work. When the hourly execution time rolls around the script doesn't run and I get an email from cron saying "/bin/bash: line 1: root: command not found". /bin/bash exists and /bin is included in the PATH. Anyone have any ideas what to try next?

Mike
# 2  
Old 06-21-2012
Did you edit that script in Windows Notepad? It will be filled with carriage returns which will be taken as literal parts of strings...
# 3  
Old 06-21-2012
No, I used crontab -e. I think the editor is vi.
# 4  
Old 06-21-2012
I mean the script that cron is running.
# 5  
Old 06-21-2012
The problem isn't with the script. I can comment out the script and get the same problem. The problem is that cron stops at the very first line that says "SHELL=/bin/bash" and returns the fact that it can't find bash.
# 6  
Old 06-21-2012
Not all crons support the SHELL statement. Do you actually need the bash shell for your crontab?
# 7  
Old 06-21-2012
Well, that was an interesting question. I tried commenting out the Path statement and now I get "/bin/sh: line 1: root: command not found". So apparently cron doesn't count the lines containing PATH, HOME, SHELL, etc. So now I can focus on the actual command as the problem.

When I first ran crontab -e I got a default file that looked like this:
Code:
# /etc/crontab
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
HOME=/var/log
#
#minute hour    mday    month   wday    who     command
#
#
# Run daily/weekly/monthly jobs.
00      *       *       *       *       root    periodic daily
30      4       *       *       6       root    periodic weekly
30      5       1       *       *       root    periodic monthly

When I couldn't get things to work I tried changing /bin/sh to /bin/bash since that's what Terminal seems to default to. I just read this on another forum:

"If the users account has a crontab but no useable shell in /etc/passwd then the cronjob will not run. You will have to give the account a shell for the crontab to run."

That sounds like my problem but I have no idea how to "give the account a shell".

Thoughts?

(And thanks, btw, for your help.)

Mike

Last edited by Franklin52; 06-22-2012 at 03:44 AM.. Reason: Please use code tags for data and code samples
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Email Notifications on Cron Bash Error Only cp mv rsync

Wondering if anyone can point me to an example of how to setup a bash script that executes cp mv and rsync commands and only sends an email if there were errors with any of those commands and what the errors are. In addition it should email if the cron event to execute the script fails, or in... (1 Reply)
Discussion started by: consultant
1 Replies

2. Shell Programming and Scripting

BASH Slow Under Cron Only!

I've got a BASH script that runs much faster from the command line than when invoked under CRON. Ideas? Priority? IO? (1 Reply)
Discussion started by: gmark99
1 Replies

3. Shell Programming and Scripting

Calling bash script works when called manually but not via Cron?

Hi, I've got a Bash backup script I'm trying to run on a directory via a cron job nightly. If I ssh in and run the script manually it works flawlessly. If I set up the cron to run evertything is totally messed up I don't even know where to begin. Basically the path structure is ... (6 Replies)
Discussion started by: wyclef
6 Replies

4. Shell Programming and Scripting

Bash/cron issues

Hi all, I am trying to run a cronjob to push my files to my git repo once a week and output a prompt to a logfile, my script works fine if I invoke it manually but my cronjob wont run for some reason, I have sourced the file, and restarted my Mac to no avail, right now I believe I have the cronjob... (8 Replies)
Discussion started by: gmenfan83
8 Replies

5. Shell Programming and Scripting

Bash Shell Script and Cron

How can I tell a script to only execute if the other scripts exits successfully? So "script A" executes and if it executes successfully (0),then "script B" will run or else "script A "executes and it exits unsucessfully (1) then "script B" will read return code (1) and will not execute ... (3 Replies)
Discussion started by: metallica1973
3 Replies

6. Shell Programming and Scripting

how do I run bash script using cron job

How do I run bash script using a cron job? I have tried to just write the path of the script, but that didn't work. (1 Reply)
Discussion started by: locoroco
1 Replies

7. Shell Programming and Scripting

bash unix cron + sending sms

Hi all, i'm trying to send an sms (notification sms) via a bash script executing throw crontab. The script works fine, but the sms itsn't sent to me. can you help me to resolve this issue, plz. Thanks. Yes - we probably COULD help you if you WOULD provide us with your script, the... (0 Replies)
Discussion started by: arezki76
0 Replies

8. Shell Programming and Scripting

changing cron using bash script

How can I change the cron entries only for ABC and XYZ from dosomething_1.0.sh to nowchanged_2.0 using a bash script ? Any help will be appreciated. # # ABC 00,05,10,15,20,25,30,35,40,45,50,55 * * * * /mydir/dosomething_1.0.sh 1>/dev/null 2>&1 # # ## # DEF... (4 Replies)
Discussion started by: jville
4 Replies

9. UNIX for Dummies Questions & Answers

bash: cron-config: command not found - PLEASE HELP ME!!

Hello All, I have installed Cygwin on Windows XP and working with some Shell scripting work, I have needed to schedule my script using the cornetab and whatever commands such as "cron", "cron-config" are not working in my cygwin shell, I re-installed the Cygwin but the same problem is with... (2 Replies)
Discussion started by: sriya
2 Replies

10. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

Hello, I create a file touch 1201093003 fichcomp and inside a repertory (which hava a lot of files) I want to list all files created before this file : find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long but i make a filter all... (1 Reply)
Discussion started by: yacsil
1 Replies
Login or Register to Ask a Question