Commands to call script work from command line but not from Cron entry
My first post evidently did not materialize so I posted it again:
Runnning a cron job every 5 mins to send data files to a state facility.
My original cron entry at worked fine:
Somewhere I have a problem picking up all the files so I wanted to capture all output from the script into a log file so I did this:
I am not sure if the entrie cron is failing or if just the log file isd not getting created. When I do it from the command line, the log file gets created and filled with my verbose output from the script.
Is there something special to do with my syntax in the cron entry ?
Thread: Commands to call script work from command line but not from Cron entry Edit Post
---------- Post updated at 04:46 PM ---------- Previous update was at 04:38 PM ----------
I don't know why I had the "tee" in there. Probably used it while I was testing. I have since taken it out:
Last edited by Skyybugg; 12-26-2013 at 05:41 PM..
Reason: Fixed CODE tags
There is no tty, no /dev/tty, no controlling terminal. You can create one in several ways, like ssh -tt and expect, but usually one does not want terminal output from a cron job.
You have to build the environment manually, and if you were not careful writing your ~/.profile, it may want a tty. Without the usual PATH, LD_LIBRARY_PATH, etc. many apps fail.
Execuatble scripts should be set up according to man exec to run under the right interpreter. Cron will call scripts using sh, and if you lack exec permissions or first line is not:
then you are in trouble.
I often test run cron script lines using something like:
(no terminal, called from sh).
0
I have a script(main.sh) which calls another script(Get_Files.sh) and gets a value in a variable like the below:
File_to_Refresh="$(sh /Aug/work/Get_Files.sh /Aug/Work/Universal_File.txt)"
Now I have to schedule the script main.sh for 3 different files i.e. the Universal_File.txt with 3... (2 Replies)
Hi
I have a text file (Input.txt) with two column entries separated by tab as given below:
aaa str1
bbb str2
cccccc str3
dddd str4
eee str3
ssss str2
sdf str3
hhh str1
fff str2
ccc str3
.....
.....
..... (1 Reply)
Hi, I have a script that seems to run to completion when in the command-line, but when it is run using the cron, it seems to time out.
They both start and run fine, but on the CRON it stops prematurely.
The script hits an API every few seconds and grabs data.
Does anyone have any idea on... (4 Replies)
In my cron thare is a line like
24 11 * * * /usr/batch/bin/abc.sh > /usr/batch/log/abc.log 2>&1
along with other entries. I want to comment out this line through a shell script. My local variable 'line'ontains the full entry (i.e. 24 11 * * * /usr/batch/bin/abc.sh > /usr/batch/log/abc.log... (4 Replies)
Hi all,
I have a script that can be run via cron or via the command line.
Is there any way that I can place something on the script to be able to distinguish/differentiate whether the script was run via a user in the command line or whether it was run from the cron? (3 Replies)
Hi, I'm new to these forums, and I'm hoping that someone can solve this problem...
To make things short:
I have DD-wrt set up on a router.
I'm trying to run a script in CRON that fetches the daily password from my database using SSH.
CRON is set like so(in web interface):
* * * *... (4 Replies)
I have a script which runs fine through command line, but doesn't run through cron. There are some variables which are set by the .profile file which are used by the script. Is it that cront does not pick these variables.
$/export/home/rahul/bin/createfile.sh >>... (3 Replies)
Hey there, I'm a total newbie unix guy here and just picking this stuff up. Have a very small script I put together that works fine from the command line but not once I put it in a cron job. Searched and found this thread and am wondering it it has something to do with setting variables, though the... (7 Replies)
Howdie everyone...
I have a shell script RemoveFiles.sh
Inside this file, it only has two commands as below:
rm -f ../../reportToday/temp/*
rm -f ../../report/*
My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Hello,
I'm stuck and confused as to why when I execute things form the command line it works but when in a script it doesn't.
My script:
### creating a lock on the console
touch /var/run/console.lock
chmod 600 /var/run/console.lock
echo "$User" >>... (2 Replies)