Thanks Methyl,
I used the following command
for croning the script and now a blank abc.log file is getting generated at the path home/myfolder and the time stamp of the blank abc.log file also gets updated after every 5 minutes. But seems the shell script is still not getting executed.
-> the script is written to transfer .dmp file from unix server to a windows OS server using ftp. the script first zips the .dmp file and than transfers it.
-> when logging to the unix system through putty and executing the following command manually:
sh abc.sh
the script executes properly and the file gets transferred to the home directory of the apache server installed in the windows system.
-> I have been granted a user account in this unix server. 'myfolder' is the folder by my name located at the path: root/home/myfolder. -> I have placed the script 'abc.sh' in this 'myfolder' as i have access to only this folder and i can't access any other folder in the system. The .dmp file is also located in the same folder as the script. The blank abc.log file is generated at the same folder. -> The 'my_ARCHIVE' folder is created in the folder 'myfolder'. The script after copying the file to the windows system should move the file to this 'my_ARCHIVE' folder.
Question: Is this issue related to access and permissions? I am the owner of the crontab and the crontab is expected to execute the shell script which is present in the folder where i have read-write access. Is it that the cron job is not able to access the script? If thats the case, how can it be confirmed and what permissions need to be granted to me for the same?
Thanks.
---------- Post updated at 05:56 PM ---------- Previous update was at 05:40 PM ----------
Hi Corona688,
I entered the profile path as mentioned below but still the cron job not able to execute the shell script.
Any help would be appreciated.
Last edited by methyl; 07-04-2012 at 07:37 PM..
Reason: please use code tags
Thanks Methyl,
I used the following command
for croning the script and now a blank abc.log file is getting generated at the path home/myfolder and the time stamp of the blank abc.log file also gets updated after every 5 minutes. But seems the shell script is still not getting executed.
If it's generating abc.log, it is running.
As for why it's not working, post the contents of the script so we can see.
for croning the script and now a blank abc.log file is getting generated at the path home/myfolder and the time stamp of the blank abc.log file also gets updated after every 5 minutes. But seems the shell script is still not getting executed.
Please post:
# From the local server (blotting anything confidential with X's). root/home/myfolder is not an absolute path. Where is the directory in the filesystem?
Please post what Operating System and version you are running and what Shell this is, blotting anything confidential like computer names and licences with X's.
The script /home/myfolder/abc.sh as posted is rather buggy. All is does is execute a large echo of everything between the two double quote characters and dumps it into a new file called ftp in the current working directory! You may wish to find this output file, check the contents and then delete it.
The script itself needs to positively state directory names and also needs to use ftp -i to stop ftp prompting after every file in a mput.
Folder names came from your narrative. I can't claim to fully understand your folder structure, so do check it.
In you post you say that your Shell is /bin/bash but your shebang line at the top of the script says /bin/sh. On some systems they are actually the same program, but do check.
This suggested code is to demonstrate the correct structure for the script (minus the echo) and to illustrate the need to have a cd to give filenames some context when running from cron.
Untested.
Consider commenting out the rm line while testing and do make sure that you have a copy of your *.dmp files so you can test again and again.
Hi Methyl,
I tested the script with contents as mentioned by you but that did'nt work through cron job.
In order to test if the issue is related to wrong scripting ode, I created the following simple script.
This script if executed manually through putty: sh xyz.sh removes the .dmp file from the myfolder.
The same script when cronned: generates a blank log file but does not removes the .dmp file.
I am really not sure whatss going wrong now.
Last edited by methyl; 07-05-2012 at 03:35 PM..
Reason: please use code tags
Hello Lads,
I deployed a script on my mac to start and stop EC2 instances on AWS console. The script when started manually on the terminal does the expected stop and start. Problem is when i try to schedule it on a cron, it fails to recognize the AWS Keys which i set up as ENV variable by... (2 Replies)
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)
I get a different output when i manually run the .sh script and when it is run by a cron job. Please help me ..
TMP1="/lhome/bbuser/script/wslog/sar.t1"
TMP2="/lhome/bbuser/script/wslog/sar.t2"
TMP3="/lhome/bbuser/script/wslog/sar.t3"
OUTPUT="/lhome/bbuser/script/wslog/sar.out"... (8 Replies)
Hello Team,
As a part of my job we have made a script to automate a service to restart frequently.
Script having two functions when executing it's should find the existing service and kill it, then start the same service . Verified the script it's working fine when executing... (18 Replies)
Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered.
The script is as follow:
#!/bin/sh
for file in file_1.txt file_2.txt file_3.txt
do
awk '{ print "0" }' $file > tmp.tmp
mv tmp.tmp $file
done
And the cron... (2 Replies)
Hello Guys,
I have scratched my head alot on this but couldn't find clue what's wrong. Can you please help me with this? My problem is as following.
1) When I manually execute following script it runs successfully with below output.
bash-3.00# more smssend
#!/bin/bash
echo -e "<Request... (16 Replies)
Hello,
I am working one one script where I am using the below code which is using to connect with MKS client when I run my script manually it works effiecently i.e. it connects with MKS client but when I run it from CRON it doesn't connect.
1)Can some one tell when it is running from cron... (1 Reply)
Hi
Script not getting executed via cron but executes successfully when executed manually. Please assist
cbspsap01(appuser) /app/scripts > cat restart.sh
#!/bin/ksh
cd /app/bin
date >>logfile.out
echo "Restart has been started....." >>logfile.out
date >>logfile.out
initfnsw -y restart... (3 Replies)
I have a very basic script that essentially sends a log file, via FTP, to a backup server. My cron entry to run this every night is:
55 23 * * * /usr/bin/archive_logs
The script runs perfectly when executed manually, and actually worked via cron for about three weeks. However, it mysteriously... (3 Replies)