I wrote a script and set it as a cron job to automatically download the data from the website.
Here is the problem, when I run this script in terminal, it works well, while it can not download the files when I run it as a cron job, I feel so weird.
The script as follows:
v#!/bin/csh
# name: auto_download_all
# Purpose: automatically download, change directory and reformat for all stations
# Output: txt and csv -formatted file
set directory1 = '/data/gipsy/bin/chen/nwcc_web_report_scripting'
set directory2 = '/data/gipsy/bin/chen'
set directory3 = '/usr/local/apache/htdocs/i/snow/in_situ/by_product/snotel'
set gps_num = `cat /gipsy/files/gps_snotel2.txt | awk '{if ($1 != "#" && $4 <25000) print substr($1,1,4)}' | tr '[A-Z]' '[a-z]'`
set snotel_num = `cat /gipsy/files/gps_snotel2.txt | awk '{if ($1 != "#" && $4 <25000) print substr($3,1,3)}' | tr '[A-Z]' '[a-z]'`
foreach site_num($gps_num)
set snotel = `snotelID $site_num`
#download file
$directory1/gethistoric.sh $snotel ALL Daily 2012 CY
# move the file to a new dir
mv $directory2/${snotel}-2012CY.csv $directory3/${site_num}/${snotel}-2012CY.csv
end
Do you guys have any solutions about it? Thank you very much!
Could you please kindly tell me what should I put '. ~/.profile ' and 'set -x' in the script? Could you just give me the full edition of the correct script? I am sorry I am new here, thank you very much.
When I input as you told me, it asked: 'Do you want to retry the same edit? ' And I said: no, then it said: 'crontab: edits left in /tmp/crontab.XXXXF72RjH'
But when I reopen the crontab by crontab -e, it doesn't changed. And at the bottom of the terminal , it said: '"/tmp/crontab.XXXXLXEy6w" 3L, 142C'