Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 13th October 2012, 22:57
frosty frosty is offline
Junior Member
 
Join Date: Oct 2012
Location: United Kingdom
Posts: 7
Thanks: 7
Thanked 0 Times in 0 Posts
Default sh: ... No such file or directory

Hello there,

While trying to invoke my test shell script via crontab, I am bumping into "sh: my_shell_script.sh: No such file or directory" error message. The same script however executes just fine when invoked manually from the Putty ssh terminal, like "./my_shell_script.sh".

The directory where the script resides exists, has 755 permissions set recursively and I can access it/write into it via my FTP client without any problem.

The script my_shell_script.sh itself is just a test script outputting "Hello world":

#!/bin/bash
echo "Hello world"

The invoking this shell script crontab crontab.txt file goes as follows:

MAILTO=my_email_address@abc.com
30 * * * * sh ./my_shell_script

I know that the cronjob to invoke the my_shell_script.sh gets created as running "crontab -l" plus receiving emails proves.

I've written it under my Ubuntu Linux using Kate editor, so it doesn't contain any Windows generated unnecessary characters. The folder where this shell script resides is 755.

I am not sure if it would help, but I've run echo %PATH and it's output is:

/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin

Also, this scenario occurs on my remote hosting account which I am allowed to access via SSH.

Looking forward to hearing from honourable gurus.

Cheers

Alex
Reply With Quote
Sponsored Links
  #2  
Old 14th October 2012, 18:32
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

Please use the full path to the script in your cron line.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
The Following User Says Thank You to falko For This Useful Post:
frosty (14th October 2012)
  #3  
Old 14th October 2012, 20:33
frosty frosty is offline
Junior Member
 
Join Date: Oct 2012
Location: United Kingdom
Posts: 7
Thanks: 7
Thanked 0 Times in 0 Posts
Default Full path to a shell script

Thank you for your answer, falko.

I've tried:

MAILTO=my_email_address@abc.com
30 * * * * sh /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin/my_shell_script

and

MAILTO=my_email_address@abc.com
30 * * * * sh /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin/.my_shell_script

(just playing with keeping/not keeping dot in front of the shell script name at the end of the path)

both instances - no joy: the same

"sh: /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin/backup/democronjobs/my_shell_script: No such file or directory"

and

"sh: /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin/backup/democronjobs/.my_shell_script: No such file or directory"

error messages in my mailbox.

Cheers,

Alex
Reply With Quote
  #4  
Old 15th October 2012, 08:36
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,763
Thanks: 821
Thanked 5,331 Times in 4,183 Posts
Default

Run the command:

which sh

to get the full path of the sh interpreter. The replace "sh" in your cron commands with the full path to the sh interpreter.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
frosty (15th October 2012)
  #5  
Old 15th October 2012, 13:15
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,740 Times in 2,575 Posts
Default

/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin/backup/democronjobs/my_shell_script is no path.

I guess you mean /opt/dell/srvadmin/bin/backup/democronjobs/my_shell_script so try that one.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
The Following User Says Thank You to falko For This Useful Post:
frosty (15th October 2012)
  #6  
Old 15th October 2012, 14:20
frosty frosty is offline
Junior Member
 
Join Date: Oct 2012
Location: United Kingdom
Posts: 7
Thanks: 7
Thanked 0 Times in 0 Posts
Default Testing /opt/dell/srvadmin/bin/backup/democronjobs/my_shell_script

Thank you for your quick reply.

the "which sh" produced /bin/sh

I've run my cronjob.txt file with the suggested path /opt/dell/srvadmin/bin/backup/democronjobs/my_shell_script as

MAILTO=abc@abc.com
57 * * * * /bin/sh /opt/dell/srvadmin/bin/backup/democronjobs/.my_shell_script

as well as

MAILTO=abc@abc.com
57 * * * * /bin/sh /opt/dell/srvadmin/bin/backup/democronjobs/my_shell_script

The same "No such file or directory" error message persists.

Cheers,

Alex

Last edited by frosty; 15th October 2012 at 15:18.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron issue in Debian 6 Nolan Installation/Configuration 6 18th April 2011 16:36
ISPConfig install issues... flyingaggie Installation/Configuration 2 18th July 2008 10:46
add web site serr57 Installation/Configuration 18 13th April 2008 11:40
Chroot SSH + ISPConfig Norman Installation/Configuration 27 26th March 2007 03:40
setup fails on debian 3.1 dtrumbower Installation/Configuration 7 7th March 2006 13:42


All times are GMT +2. The time now is 01:50.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.