Jump to content

Command won't execute on startup from /usr/local/bin (Ubuntu command line 16.0.4)

babadoctor
Go to solution Solved by babadoctor,
2 hours ago, colonel_mortis said:

Are there any errors being generated by crontab? Assuming you are running as the babadoctor account, they should be logged to /var/mail/babadoctor.

Is the script executable? if you run ls -l /usr/local/bin/yourScript.sh, does it have x in all the permission masks? If not, try making it executable using chmod +x /usr/local/bin/yourScript.sh.

Are you specifying the whole path in crontab, or just the script name? Try specifying the full path (/usr/local/bin/yourScript.sh) if you aren't already.

So, the solution to this issue was to move it from /usr/local/bin to /usr/bin

It executes the same and works fine.

 

var/mail/babadoctor is empty.

The script is executable, but has no shebang, as I don't think it needs one. (other /usr/bin script doesnt have one and executes)

I am also executing the entire path in crontab, as it executes the first file fine.

So, I have a crontab command that executes a script file at startup. This executes successfully, as I can see that it creates a tmux/screen with a command that I asked it to run.

The only problem I have is that any programs that exist in the directory /usr/local/bin/ won't execute for some odd reason, while programs in /usr/bin will execute... Any ideas why?

 

The contents of the file that crontab executes (.sh file) looks like this:

screen -dmS Script1 bash -c 'sh /home/babadoctor/ScriptRunningProgramFromBin.sh'
sleep 2 
//I tried sleep to see if timing was an error/ if the command had not loaded up? For some odd reason it would not execute and throw the error of the program not being able to be found
screen -dmS Script2 bash -c 'sh /home/babadoctor/directory1/directory2/ScriptRunningProgramFromLocal.sh'

 

The flow of execution for the files looks like this:

crontab > .sh file which executes other scripts (allows easy access and editability so i dont need to mess around with crontab any more) 

> other scripts (this includes any script I want to execute)

 

Yeah, I know it is a very hacky and bad way of doing this (Is it really?), but I really hate editing crontab, and I feel like editing the file that crontab executes is easier and more accessible for me...

 

 

So, I have gotten it to execute programs that run from /usr/bin/ successfully, but I could not get it to execute programs that were located in /usr/local/bin/.

I don't know why this is, and I would like to know how I can work around this. 

Any ideas?

 

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

Are there any errors being generated by crontab? Assuming you are running as the babadoctor account, they should be logged to /var/mail/babadoctor.

Is the script executable? if you run ls -l /usr/local/bin/yourScript.sh, does it have x in all the permission masks? If not, try making it executable using chmod +x /usr/local/bin/yourScript.sh.

Are you specifying the whole path in crontab, or just the script name? Try specifying the full path (/usr/local/bin/yourScript.sh) if you aren't already.

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, colonel_mortis said:

Are there any errors being generated by crontab? Assuming you are running as the babadoctor account, they should be logged to /var/mail/babadoctor.

Is the script executable? if you run ls -l /usr/local/bin/yourScript.sh, does it have x in all the permission masks? If not, try making it executable using chmod +x /usr/local/bin/yourScript.sh.

Are you specifying the whole path in crontab, or just the script name? Try specifying the full path (/usr/local/bin/yourScript.sh) if you aren't already.

So, the solution to this issue was to move it from /usr/local/bin to /usr/bin

It executes the same and works fine.

 

var/mail/babadoctor is empty.

The script is executable, but has no shebang, as I don't think it needs one. (other /usr/bin script doesnt have one and executes)

I am also executing the entire path in crontab, as it executes the first file fine.

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

6 hours ago, babadoctor said:

So, the solution to this issue was to move it from /usr/local/bin to /usr/bin

It executes the same and works fine.

 

var/mail/babadoctor is empty.

The script is executable, but has no shebang, as I don't think it needs one. (other /usr/bin script doesnt have one and executes)

I am also executing the entire path in crontab, as it executes the first file fine.

In your script if you specify the full path to the command it will likely work. I would assume that /usr/local/bin/ is not in the path of the screen session shell.

 

I am not talking about the path to the script in your crontab but the path to the command in your script.

 

so in 

/home/babadoctor/directory1/directory2/ScriptRunningProgramFromLocal.sh

replace all instances of 

commandThatWontRun

with 

/usr/local/bin/commandThatWontRun

 

These kinds of things are way easier to understand and tell you how to fix if you include more information right from the get go. what is the command, show the full contents of the script, what is the actual behavior that you are experiencing... that kind of thing.

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, SpaceNugget said:

In your script if you specify the full path to the command it will likely work. I would assume that /usr/local/bin/ is not in the path of the screen session shell.

 

I am not talking about the path to the script in your crontab but the path to the command in your script.

 

so in 


/home/babadoctor/directory1/directory2/ScriptRunningProgramFromLocal.sh

replace all instances of 


commandThatWontRun

with 


/usr/local/bin/commandThatWontRun

 

These kinds of things are way easier to understand and tell you how to fix if you include more information right from the get go. what is the command, show the full contents of the script, what is the actual behavior that you are experiencing... that kind of thing.

Oh, I see!
I could just specify the program path, instead of trying to execute its alias!

I totally get it now!
Thanks so much!

OFF TOPIC: I suggest every poll from now on to have "**CK EA" option instead of "Other"

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×