Sponsored Content
Full Discussion: CRON job still running?
Top Forums Shell Programming and Scripting CRON job still running? Post 302862829 by sea on Friday 11th of October 2013 02:13:41 PM
Old 10-11-2013
I'd rather write the PID of your cronscript to that tempfile, so you can check right away if the process is still running or not, by matching ps $(cat tempfile).

So in your cron script you do something like:
Code:
doit=false
[[ ! -f tempfile ]] && doit=true
[[ -f tempfile ]] && [[ ! $(ps $(cat tempfile) ]] && doit=true

if [[ $doit ]];then
      echo $$ > tempfile

      echo "your code"

      rm -f tempfile
fi


Hope this helps

NOTE: For cron scripts you need to write full paths to commands, not like this example!
This User Gave Thanks to sea For This Post:
 

10 More Discussions You Might Find Interesting

1. HP-UX

Cron Job Not Running

Hi, I have a cron schedule like this 04,16,28,40,52 * * * * /nag/startProcessABatch (unix script) i want to add new lines in this file (like Logging), i just copy this file into a /tmp folder (for backup copy), and i have edited this file (added few lines of code for logging). ... (1 Reply)
Discussion started by: nag_sundaram
1 Replies

2. UNIX for Advanced & Expert Users

cron job is not running

hi, i have the following line in the crontab 15 5 * * 6 /home/adw/BCE_ADW.pl The problem is the cron job is not getting started automatically. But this was working til last week. now it is not working. what could be the problem. Any idea? (3 Replies)
Discussion started by: Suguna
3 Replies

3. UNIX for Dummies Questions & Answers

cron job not running to completion

am running a cron job to do a backup of all user files. the script runs properly in the terminal but only backups about 20% of the files when run by cron. the Linux system is running BASH as far as I can tell. the symbols $FILE and $DIRECTORY are defined properly and the following is the... (1 Reply)
Discussion started by: novice633
1 Replies

4. UNIX for Dummies Questions & Answers

Cron job not running

Hi All, I am editing crontab using -e option to add a new job Below is the line 30 * * * * scriptpath This job is not executing every thirty minutes. I have checked, cron daemon is running. What did I miss? Can some one help? I am using cron shell..ksh (7 Replies)
Discussion started by: yabhi_22
7 Replies

5. Shell Programming and Scripting

running Cron job in Plesk

I have a script to delete unwanted cookies from some Curl jobs we are doing find /tmp -name 'CURLCOOKIE*' -print0 | xargs -0 rm this works great when I am logged on as root in the shell, now I have to put it into a cron job in Plesk. When I do that it does not work. I think the directory... (0 Replies)
Discussion started by: vaene
0 Replies

6. UNIX for Dummies Questions & Answers

Problem running a cron job

I have created a cron job for the vtiger workflow to execute the shell file named com_vtiger_workflow.sh to run the workflow. I've created the following line in crotab -e : 00 13 * * * /var/www/html/prashant/cron/modules/com_vtiger_workflow/com_vtiger_tiger_workflow.sh | mail -s 'Check... (2 Replies)
Discussion started by: anaigini45
2 Replies

7. Shell Programming and Scripting

Cron job running problem

Hi Guys, I am trying to run a script through contab. The script can only be executed once user logs in as su - oracle. I have tested the script other then cronjob and it executes successfully, more over the paths used in the script are absolute paths. Crontab entries are as as below.... (3 Replies)
Discussion started by: Asteroid
3 Replies

8. UNIX for Dummies Questions & Answers

Cron is running,but my job is not triggering.

Hi, I have scheduled a job previously and was running fine,but due to some issue i have commented it.Now the issue was solved and i have scheduled as below in crontab. 30 2 * * * /u01/srcdata/CSA/holding/common/script/QPLR_RegValrao.sh PROD Cron is running,but my job is not triggering. ... (1 Reply)
Discussion started by: mvennakula
1 Replies

9. Solaris

Cron job is not running

Hi, I have set up the crontab as follows. root@IDC4VASAPP07 # crontab -l 0-59 * * * * /var/tmp/r.sh 0-59 * * * * date >> /var/tmp/log root@IDC4VASAPP07 # r.sh is as follows. root@IDC4VASAPP07 # cat r.sh #!/bin/bash dt1=$(perl -e 'use POSIX;print strftime... (10 Replies)
Discussion started by: SunilB2011
10 Replies

10. Solaris

Cron job running even after cron is removed

Hi , I have removed a cron for particular user , but cron job seems to be running even after the cron entry is removed. The purpose of the cron was to sendmail to user ( it uses mailx utility ) I have restarted cron and sendmail service still user is getting mail alerts from the cron job. And... (4 Replies)
Discussion started by: chidori
4 Replies
ANACRONTAB(5)							   File Formats 						     ANACRONTAB(5)

NAME
/etc/anacrontab - configuration file for Anacron DESCRIPTION
The /etc/anacrontab configuration file describes the jobs controlled by anacron(8). It can contain three types of lines: job-description lines, environment assignments, or empty lines. Job-description lines can have the following format: period in days delay in minutes job-identifier command The period in days variable specifies the frequency of execution of a job in days. This variable can be represented by an integer or a macro (@daily, @weekly, @monthly), where @daily denotes the same value as the integer 1, @weekly the same as 7, and @monthly specifies that the job is run once a month, independent on the length of the month. The delay in minutes variable specifies the number of minutes anacron waits, if necessary, before executing a job. This variable is repre- sented by an integer where 0 means no delay. The job-identifier variable specifies a unique name of a job which is used in the log files. The command variable specifies the command to execute. The command can either be a command such as ls /proc >> /tmp/proc or a command to execute a custom script. Environment assignment lines can have the following format: VAR=VALUE Any spaces around VAR are removed. No spaces around VALUE are allowed (unless you want them to be part of the value). The specified assignment takes effect from the next line until the end of the file, or to the next assignment of the same variable. The START_HOURS_RANGE variable defines an interval (in hours) when scheduled jobs can be run. In case this time interval is missed, for example, due to a power down, then scheduled jobs are not executed that day. The RANDOM_DELAY variable denotes the maximum number of minutes that will be added to the delay in minutes variable which is specified for each job. A RANDOM_DELAY set to 12 would therefore add, randomly, between 0 and 12 minutes to the delay in minutes for each job in that particular anacrontab. When set to 0, no random delay is added. Empty lines are either blank lines, line containing white spaces only, or lines with white spaces followed by a '#' followed by an arbi- trary comment. You can continue a line onto the next line by adding a '' at the end of it. In case you want to disable Anacron, add the 0anacron cron job (which is a part of crontab(1)) into the /etc/cron.hourly/jobs.deny direc- tory. EXAMPLE
This example shows how to set up an Anacron job similar in functionality to /etc/crontab which starts all regular jobs between 6:00 and 8:00 only. A RANDOM_DELAY which can be 30 minutes at the most is specified. Jobs will run serialized in a queue where each job is started only after the previous one is finished. # environment variables SHELL=/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root RANDOM_DELAY=30 # Anacron jobs will start between 6am and 8am. START_HOURS_RANGE=6-8 # delay will be 5 minutes + RANDOM_DELAY for cron.daily 1 5 cron.daily nice run-parts /etc/cron.daily 7 0 cron.weekly nice run-parts /etc/cron.weekly @monthly 0 cron.monthly nice run-parts /etc/cron.monthly SEE ALSO
anacron(8), crontab(1) The Anacron README file. AUTHOR
Itai Tzur <itzur@actcom.co.il> Currently maintained by Pascal Hakim <pasc@(debian.org|redellipse.net)>. For Fedora, maintained by Marcela Malaova <mmaslano@redhat.com>. cronie 2012-11-22 ANACRONTAB(5)
All times are GMT -4. The time now is 09:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy