In what way is ~/.profile not working? Please show us the exact output it produces (in CODE tags).
Most problems that we see in this forum where something works when run from a login shell but fails when run by cron are because:
A different shell than your login shell is being used by cron to run scripts.
Your shell's initialization scripts that are run when you login are not being run by cron so environment variables that your script may depend up have not been set.
Your login shell runs scripts in an interactive environment; cron runs jobs without connection to a controlling terminal so there is no way for you as a user to respond to prompts written by your script.
Yoda's suggestion to run ~/.profile was an attempt to set the environment variables usually set by your login shell for the cron job you are running. But that suggestion makes some assumptions about what shell you use as your login shell and about the shell used by cron to run jobs on your operating system.
There have been questions asked that you didn't answer yet. Your chances of getting a reasonable hint depend on / increase with your answers given... You should supply any detail possible for error analysis and elimination.
If you could post the output (in CODE tags) from these commands, that will give us a start:-
When you log in (or start a new terminal) what gets displayed on your screen? Paste the screen text highlighting any errors into the thread, again in CODE tags or paste an image if you can do that.
I'm assuming that you run the script with the same account both from the command line and from cron, but please confirm the user(s) and their UID with id on the command line and pasting in the relevant line from crontab -l or copied from /etc/cron.d/whatever-you-called-it, or that could be /etc/cron.hourly/whatever or other variation, but I presume you know which one is is written in. It would be useful to know.
For differences between your login shell and the environment provided when cron runs something, can you do this:-
Then write yourself a small script containing:
.... and run it with cron, just the once will be fine, but don't use at because that will use your login shell environment too.
Did you take Corona688's suggestion to create ssh-keys in post 4? This would simplify your script somewhat.
Did you take Yoda's suggestion in post 6? Can you paste the error file it wrote? (in CODE tags) Perhaps run with and without the leading ~/.profile ; so we can see if the difference is useful.
If you answer the questions raised, then people will be happy to help, but without this information we're just guessing blind. We do not know what your server has set up.
I hope that this helps you help us to help you,
Robin
---------- Post updated 02-13-18 at 12:03 AM ---------- Previous update was 02-12-18 at 11:49 PM ----------
the content of login_set.txt
---------- Post updated at 12:10 AM ---------- Previous update was at 12:03 AM ----------
Yoda and Corona suggestions did not work, because the file log is not being created, and the file is not being sent to the remote server. As i said my issue is to get the file to the remote server using cron. When using the script suggested by Corona there's no output at all. Even when i add this
, i have no file log created
---------- Post updated at 05:42 PM ---------- Previous update was at 12:10 AM ----------
Hello,
The given information is not enough?or is something i'm not doing right?can someone tell me something?
---------- Post updated 02-14-18 at 03:20 AM ---------- Previous update was 02-13-18 at 05:42 PM ----------
Hello,
I have a situation with crontab command on AIX , when i run a script with crontab i receive empty output , when i run it manually i have information in it,beside the empty output ,SAS log is empty too, i don't know why isn't creating it , could someone told me how could verify crontab... (3 Replies)
hi guys,
i need a script to sftp the file from windows to unix server ....(before that i have to check whether the file exists in the windows server or not
and again i have to reverse sftp the files from unix to windows server.....
regards,
Vasa Saikumar. (13 Replies)
I had the below sftp script working perfectly but the problem is I am not able to send the echo statements .
#!/bin/sh
echo "Starting to sftp..."
sftp admin@myip << END_SCRIPT
cd /remotepath/
lcd /localpath/
mget myfiles*.csv
bye
END_SCRIPT
echo "Sftp successfully."
echo
echo... (11 Replies)
Hello,
I have a weird issue, I have RHEL 5.7 running with openssh5.2 where sftpgroup OS group is chroot. I see the difference difference in timestamp on files, when I login via ssh and SFTP, I see four hour difference, is something missing in my configuration.
#pwd... (8 Replies)
Dear community,
I'm driving crazy with a strange issue.
I have a simple script to transfer a file to a remote system:#!/bin/bash
echo "put /tmp/server.log" > /tmp/server1_transfer.sftp
sftp -b /tmp/server1_transfer.sftp user@10.99.1.2:Between client and server there is a SSH KEY, so if I run... (15 Replies)
Hi,
I have situation where i need to automate transferring 10000+ files using sftp.
while read line
do
if ; then
echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt
fi
done< files.txt
sftp -b sftpCommand.txt stu@192.168.2.1
The above... (1 Reply)
Hi,
While I am trying SFTP my machine to another unix machine ,
it was working fine till 10 min back.
But now i am getting the below error
"Request for subsystem 'sftp' failed on channel 0"
Could you please someone help me to solve or analyise the root cause...
Cheers:b:,
Mahiban (0 Replies)
Hello!
I have a problem on adding a new crontab. Currently we have a running jobs scheduled on a crontab and they are all successfully running. However, when adding or inserting a new scheduled job, the script doesn't work. Is there any limitations on this?
Please advise.
Thank you very... (13 Replies)
I have made changes to crontab using: crontab -e
I then save them with :wq but the changes aren't being seen. The file mod date has not changed.
What am I doing wrong? (2 Replies)