Sponsored Content
Full Discussion: Question about cronjob
Top Forums Shell Programming and Scripting Question about cronjob Post 302592101 by handsonzhao on Sunday 22nd of January 2012 09:50:41 PM
Old 01-22-2012
Question about cronjob

Dear all,

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:
Code:
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!

Last edited by Franklin52; 01-23-2012 at 03:12 PM.. Reason: Please use code tags for data and code samples, thank you
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cronjob question

Hi folks! I set up a cronjob yesterday to excute this morning at 4am. The problem I am experiencing is that the script that is executed cannot find specified files which it is suppose to run like my file.sql and other various scripts which are in the same directory as the exucutable script. ... (4 Replies)
Discussion started by: maverick
4 Replies

2. Shell Programming and Scripting

Cronjob

Please can someone help me. I need to set up a cron job to measure CPU usage, Disk I/O and memory usage over a period of 1 minute along with the number of users logged into the system. I also need to send it to another user besides myself every hour. Please can someone help me! Thanks. (4 Replies)
Discussion started by: gerwhelan
4 Replies

3. HP-UX

CronJob

Dear Guru, I have submitted some cronjobs that has been running for quite sometimes. However, today I counter some cronjob did not run. Can you please explain what causes this to happen. Any system setting that limit number of cronjob per minutes to be started, etc? Thanks. Kelly (1 Reply)
Discussion started by: hcng08
1 Replies

4. UNIX for Dummies Questions & Answers

cronjob

hi iam new at unix.iam running a cronjob,which i want to run on the first day of every month at 1AM.this is what i have specified: 00 01 1 * * is this corect? (1 Reply)
Discussion started by: wiz83
1 Replies

5. Solaris

at vs cronjob

HI, What is the differnece between at / con job? thanks in advance. (1 Reply)
Discussion started by: mokkan
1 Replies

6. AIX

cronjob

Hi, I want to schedule a script on daily basis in morning 8:00 A.M and 5:00 P.M , how can i achieve this, i want the parameter 0 ? * * * what will be the second parameter in my case. Regards (1 Reply)
Discussion started by: maooah
1 Replies

7. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

8. UNIX for Dummies Questions & Answers

Cronjob help

Hi I am very new to linux. I want to run a cronjob every 15 minutes that checks a directory for files. If the directory contains more than ten files I want it to send an email to me. All I have is this... */15 * * * * ls -l | wc -l | | mail -s "This is just a test" I would... (2 Replies)
Discussion started by: LinuxNewb
2 Replies

9. AIX

Cronjob question about root emails.

I'm running a few cronjobs under a differnt user name that basically do the same thing: /usr/bin/find /home/userid/userid/archives -mtime +30 -type f -exec /usr/bin/gzip -1vN {} \\\; ; /usr/bin/mv /home/userid/userid/archives/*.gz /msgs/archive_msgs >/dev/null 2>&1 Seems to be working except... (12 Replies)
Discussion started by: aixnj
12 Replies

10. UNIX for Beginners Questions & Answers

Cronjob

How to set cronjob for 48 hours. I can set for 2 days as shown below. * * */2 * * It is creating confusion for 30 days & 31 days per month. (3 Replies)
Discussion started by: Nishit
3 Replies
CRON(8) 						      System Manager's Manual							   CRON(8)

NAME
cron - daemon to execute scheduled commands (Vixie Cron) SYNOPSIS
cron DESCRIPTION
Cron should be started from /etc/rc or /etc/rc.local. It will return immediately, so you don't need to start it with '&'. Cron searches /var/spool/cron for crontab files which are named after accounts in /etc/passwd; crontabs found are loaded into memory. Cron also searches for /etc/crontab and the files in the /etc/cron.d/ directory, which are in a different format (see crontab(5)). Cron then wakes up every minute, examining all stored crontabs, checking each command to see if it should be run in the current minute. When execut- ing commands, any output is mailed to the owner of the crontab (or to the user named in the MAILTO environment variable in the crontab, if such exists). Additionally, cron checks each minute to see if its spool directory's modtime (or the modtime on /etc/crontab) has changed, and if it has, cron will then examine the modtime on all crontabs and reload those which have changed. Thus cron need not be restarted whenever a crontab file is modified. Note that the Crontab(1) command updates the modtime of the spool directory whenever it changes a crontab. SEE ALSO
crontab(1), crontab(5) AUTHOR
Paul Vixie <paul@vix.com> 4th Berkeley Distribution 20 December 1993 CRON(8)
All times are GMT -4. The time now is 01:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy