HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Programming/Scripts (http://www.howtoforge.com/forums/forumdisplay.php?f=7)
-   -   sh: ... No such file or directory (http://www.howtoforge.com/forums/showthread.php?t=59084)

frosty 13th October 2012 22:57

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

falko 14th October 2012 18:32

Please use the full path to the script in your cron line.

frosty 14th October 2012 20:33

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

till 15th October 2012 08:36

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.

falko 15th October 2012 13:15

/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.

frosty 15th October 2012 14:20

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

CSARLAB 15th October 2012 23:28

hi there

are you sure you using right path for corn?
check the path and try again everything is alright

frosty 15th October 2012 23:36

Quote:

Originally Posted by CSARLAB (Post 286817)
hi there

are you sure you using right path for corn?
check the path and try again everything is alright

thank you for chipping in.

how can I find the proper path to my cron jobs? as I said a few posts above, I've run "echo $PATH" and got /usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/opt/dell/srvadmin/bin, not really sure what it is and how to use it.

Cheers,

Alex

falko 16th October 2012 13:19

What are the outputs of

Code:

ls -la /opt/dell/srvadmin/bin/backup/democronjobs/my_shell_script
and
Code:

updatedb
locate my_shell_script

? (Make sure you replace my_shell_script with the actual name of the script.)

frosty 16th October 2012 18:28

Output
 
Just drilling with "ls" into the /opt/ a have found that this folder contains only "suphp" subfolder which in turn contains only "sbin".

No wonder running the ls /opt/dell/ already produced "No such file or directory" error message.

updatedb and locate my_shell_script thrown out "command not found".

Cheers,

Alex


All times are GMT +2. The time now is 02:10.

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