LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to configure a crontask ? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-configure-a-crontask-865807/)

chandkur 03-01-2011 03:44 PM

how to configure a crontask ?
 
My shell script in /home/ddmsuser/DDMSPurge/
in my crontab this is the first line

Home = /home/ddmsuser/download-data

Whatever shell scripts present under Home are configured in the crontab.

How to configure a crontask when my script is in /home/ddmsuser/DDMSPurge/ ?

Please help.

corp769 03-01-2011 04:07 PM

This is a good reference -

http://corenominal.org/howto-setup-a-crontab-file/

When you configure crontab, you can use the full path to your script.

Josh

chandkur 03-01-2011 04:12 PM

I have already tried doing that, but it fails to run as the class file it is supposed to execute is in another location.

Dark_Helmet 03-01-2011 04:12 PM

It's not clear exactly what you want to do.

I assume you want to add the script in /home/ddmsuser/DDMSPurge/ to your existing list of cron jobs.

If so, execute crontab -e from a terminal, and add this line:

Code:

* * * * * * /home/ddmsuser/DDMSPurge/scriptname
Replace the "* * * * * *" with how frequently you want the script to run (all *'s means to run the script once every minute--see man 5 crontab for specifics)

Replace the "scriptname" with the actual filename of your script.

chandkur 03-01-2011 04:24 PM

I have already tried what you said.. and got this error ? any ideas what can be done, your help is appreciated


Quote:

From ddmsuser@wtxtt02.planet.ftn.fedex.com Tue Mar 1 17:20:01 2011
Return-Path: <ddmsuser@wtxtt02.planet.ftn.fedex.com>
Received: from wtxtt02.planet.ftn.fedex.com (localhost.localdomain [127.0.0.1])
by wtxtt02.planet.ftn.fedex.com (8.13.1/8.13.1) with ESMTP id p21MK1oU02 5108
for <ddmsuser@wtxtt02.planet.ftn.fedex.com>; Tue, 1 Mar 2011 17:20:01 -0 500
Received: (from ddmsuser@localhost)
by wtxtt02.planet.ftn.fedex.com (8.13.1/8.13.1/Submit) id p21MK1a6025107 ;
Tue, 1 Mar 2011 17:20:01 -0500
Date: Tue, 1 Mar 2011 17:20:01 -0500
Message-Id: <201103012220.p21MK1a6025107@wtxtt02.planet.ftn.fedex.com>
From: root@wtxtt02.planet.ftn.fedex.com (Cron Daemon)
To: ddmsuser@wtxtt02.planet.ftn.fedex.com
Subject: Cron <ddmsuser@WTXTT02> ./home/ddmsuser/DDMSPurge/runDDMSPurge.sh > ddm sPurge.out
Content-Type: text/plain; charset=UTF-8
X-Cron-Env: <HOME=/home/ddmsuser/download-data>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=ddmsuser>
X-Cron-Env: <USER=ddmsuser>

/bin/sh: ./home/ddmsuser/DDMSPurge/runDDMSPurge.sh: No such file or directory

Dark_Helmet 03-01-2011 04:27 PM

Quote:

/bin/sh: ./home/ddmsuser/DDMSPurge/runDDMSPurge.sh: No such file or directory
Two things:
(1) verify that runDDMSPurge.sh is the exact filename of the script (i.e. proper capitalization of the script filename and the path to the script)
(2) I don't know why there is a dot (.) at the beginning of the path. Does the dot exist in the crontab? It shouldn't.

chandkur 03-01-2011 04:29 PM

Hey thanks, I removed the dot and it seems to have kick started it.. no error mail in the spool.

The dot was there for the other jobs so I followed suit.

Thank you once again.

chrism01 03-01-2011 07:41 PM

A leading dot means start from the current dir. There's no such concept in cron, as all jobs run 'detached'. This is part of the reason you're usually advised to specify the complete absolute path to all cmds & files referenced in a cron job.


All times are GMT -5. The time now is 09:40 PM.