Issue
I want to write the crontab script for copy the file from AWS s3 folder to my local aws ec2 . I can just run the command at my linux command by
aws s3 cp s3://sftp-test/test.txt /u02/app/oracle/test/
So the test.txt file will be copy from s3 to my local u02 folder. But when i write at my command line at .sh file and then it does not work. First i create test.sh file by
#!/bin/sh
*/5 * * * * aws s3 cp s3://sftp-customs/test.txt /u02/app/oracle/test/
Second i call that crontab by
crontab test.sh
Then i can see the my script when i used
crontab -l
But overall it does not work. I don't received any file from server. Thanks for your time all. Please help with some advise.
Solution
The shell file must be like:
#!/bin/sh
source ~/.bash_profile #or .bashrc
aws s3 cp s3://sftp-customs/test.txt /u02/app/oracle/test/
and in cron (using `crontab -e) you should enter
*/5 * * * * /path/to/test.sh
alternatively create new file (test.txt
for example) with content:
*/5 * * * * /path/to/test.sh
and execute command:
crontab test.txt
NB! The last command will replace your entire cron
Answered By - Romeo Ninov