Sponsored Content
Full Discussion: Cron restarting problem
Top Forums UNIX for Dummies Questions & Answers Cron restarting problem Post 47503 by vtran4270 on Wednesday 11th of February 2004 05:51:32 PM
Old 02-11-2004
Cron restarting problem

Hi I have a script on Solaris 5.6 to restart cron /etc/init.d/cron. I have trouble restarting cron. It's all beacuse of the line:
pid=`/usr/bin/ps -e | /usr/bin/grep cron | /usr/bin/sed -e 's/^ *//' -e 's/ .*//'`
which returns not null. This is because of the system return two process which are belong to:
/etc/init.d/cron
/usr/bin/grep cron

Dows any one know how to fix this problem.
Code:
#!/bin/sh
#
# Copyright(c) 1997, by Sun Microsystems, Inc.
# All rights reserved.
#
#ident  "@(#)cron       1.11    97/04/16 SMI"   /* SVr4.0 1.3.3.1       */

#       cron control
pid=`/usr/bin/ps -e | /usr/bin/grep cron | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`

case $1 in
'start')
        echo "$pid";
        if [ "${pid}" = "" ];
        then
                /usr/bin/rm -f /etc/cron.d/FIFO
                if [ -x /usr/sbin/cron ]
                then
                        /usr/sbin/cron
                fi
        fi
        ;;
'stop')
        if [ "${pid}" != "" ]
        then
                /usr/bin/kill ${pid}
        fi
        ;;
*)
        echo "usage: /etc/init.d/cron {start|stop}"
        ;;
esac

added code tags for readability --oombera

Last edited by oombera; 02-18-2004 at 03:23 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cron problem?

here's the scoop.. I have a ksh shell script written, that when I run it manually, it works wonderful, when I let it run via cron, it runs (tells me I have it set up correctly) but yet it doesn't run correctly (it only runs part of the commands with the script). what gives? I've got the... (4 Replies)
Discussion started by: hedrict
4 Replies

2. UNIX for Dummies Questions & Answers

cron problem

In freebsd when I do crontab -l I get the result crontab:no crontab for root,yet I have a crontab in /etc and I don't know what got messed up? It was working the other day? I probably messed something up(I'm blaming me,the user). I've been wanting to have hourly emails(to my home email and not... (2 Replies)
Discussion started by: VPN
2 Replies

3. UNIX for Dummies Questions & Answers

Cron problem

Hi, I want to run my shrip for every 30 min.. if i enter crontab -l i am getting following.. 00,10,20,30,40,50 * * * * /home/arbuser/temp2/perform/per.sh 00,15,40,35,50 * * * * sh home/arbuser/temp2/perform/per.sh if I enter like this : ps -ef |grep cron root 311454 1 0... (3 Replies)
Discussion started by: redlotus72
3 Replies

4. UNIX for Dummies Questions & Answers

Cron problem

Hi, I've just done a school boy error. I was trying to edit the crontab but instead of using: crontab -e I used crontab -r without realising. Then went to look at the crontab but ntohing their. Looked int he manual and -r removed the crontab. Is their any way of getting this back?? ... (3 Replies)
Discussion started by: tez
3 Replies

5. UNIX for Advanced & Expert Users

How to solve restarting problem

Hi! My unix os version is OSF1 CP1 V4.0 878 alpha. It startup normally but it restarts within 5 sec. I would like to know how to solve . Please reply to me. Thanks . akzin (2 Replies)
Discussion started by: akzin
2 Replies

6. UNIX for Dummies Questions & Answers

cron problem

I'm using Red Hat and I need to get cron working and I'm not sure what the problem is. As a test I've done the following: 1) In /etc/cron.d I've created a file called date with the following contents 2) */1 * * * * root date >> /root/thedate 3) This works perfectly. It sends the date every... (1 Reply)
Discussion started by: kerpm
1 Replies

7. Shell Programming and Scripting

Problem with Cron

Hi i am new here and have a quick question. i am receiving ./project.sh: line 12: syntax error near unexpected token `newline' ./project.sh: line 12: `echo "`date +"%F %R"` `md5sum /etc/passwd`" >> ' error message here is my script. could you please help! #!/bin/bash # PROGRAM:... (4 Replies)
Discussion started by: mas1888
4 Replies

8. AIX

Problem with IP address when restarting AIX

Hi! I have useud SMIT to configured my static adress for AIX but when I restart the AIX the ipadress is not shown when I print netstat -in or ifconfig -a. I have to configure the ip whit smit to have it start! How can I starting the ip during boot? (6 Replies)
Discussion started by: peter.olofsson
6 Replies

9. Shell Programming and Scripting

Please help me in cron problem

When i am working with cron i given the command as crontab - e | grep runjob.sh.I though my command is wrong and i closed it by ctrl+D.After that when i need to open the cron with crontab -e its not opening its giving some number 22667 and when i given crontab -l its working fine i can see all... (5 Replies)
Discussion started by: bhas85
5 Replies

10. UNIX for Dummies Questions & Answers

Execution problem with Cron: Script works manually but not w/Cron. Why?

Hello gurus, I am making what I think is a simple db2 call from within a shell script but I am having difficulty producing the desired report when I run the script shown below from a shell script in cron. For example, my script and the crontab file setup is shown below: #!/bin/ksh db2... (3 Replies)
Discussion started by: okonita
3 Replies
CRON(8) 						      System Manager's Manual							   CRON(8)

NAME
cron - clock daemon SYNOPSIS
auth/cron [-c] DESCRIPTION
Cron executes commands at specified dates and times according to instructions in the files /cron/user/cron. It runs only on an authentica- tion server. Option -c causes cron to create /cron/user and /cron/user/cron for the current user; it can be run from any Plan 9 machine. Blank lines and lines beginning with # in these files are ignored. Entries are lines with fields minute hour day month weekday host command Command is a string, which may contain spaces, that is passed to an rc(1) running on host for execution. The first five fields are integer patterns for minute 0-59 hour 0-23 day of month 1-31 month of year 1-12 day of week 0-6; 0=Sunday The syntax for these patterns is time : '*' | range range : number | number '-' number | range ',' range Each number must be in the appropriate range. Hyphens specify inclusive ranges of valid times; commas specify lists of valid time ranges. To run the job, cron calls host and authenticates remote execution, equivalent to running rx host command (see con(1)). The user's profile is run with $service set to rx. Cron is not a reliable service. It skips commands if it cannot reach host within two minutes, or if the cron daemon is not running at the appropriate time. EXAMPLES
Here is the job that mails system news. % cat /cron/upas/cron # send system news 15 8-17, 21 *** helix /mail/lib/mailnews % SOURCE
/sys/src/cmd/auth/cron.c SEE ALSO
con(1), rc(1) CRON(8)
All times are GMT -4. The time now is 06:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy