cron + script

cron + script

Post by Claus Atzenbec » Fri, 20 Jul 2001 06:47:50



I wrote a little script which is supposed to dial into the internet, get +
send my mail and log out again For this, I created the following entry in
/etc/crontab:

30 7-23/3 * * * root    /usr/local/bin/mailXchange > /var/log/fetchmail.log

When this script is started by crond, it is all done (almost) at the same
time: dialin, fetchmail, sendmal, terminate session.

When I start this script by command line, it is working well, e.g. it does
not terminate the session before finishing fetchmail + sendmail.

It seems that crond puts a "&" at the end of every line in that script.

Here is the script:

*****
#!/bin/bash

/etc/sysconfig/network-scripts/net_cnx_up > /dev/null
sleep 2  # this line is necessary, because fetchmail would start
          # before dialing is complete

fetchmail
sendmail -q -v

/etc/sysconfig/network-scripts/net_cnx_down > /dev/null
*****

Any idea how to get this script working right with cron?

Thanks a lot!
Claus

 
 
 

cron + script

Post by M.J. Bl » Fri, 20 Jul 2001 17:11:47



> I wrote a little script which is supposed to dial into the
> internet, get + send my mail and log out again
...
> When this script is started by crond, it is all done (almost) at
> the same time: dialin, fetchmail, sendmal, terminate session.
...
> Here is the script:
> *****
> #!/bin/bash

> /etc/sysconfig/network-scripts/net_cnx_up > /dev/null
> sleep 2  # this line is necessary, because fetchmail would start
>           # before dialing is complete

> fetchmail
> sendmail -q -v

> /etc/sysconfig/network-scripts/net_cnx_down > /dev/null
> *****

> Any idea how to get this script working right with cron?

Use `wait $!` instead of sleep.

I don't know if this works with cron, but from the command line it'd
work, so I figure it works from cron aswell ;-)

On your terminal, $! represents the last pid you used. So waiting
for them, would seem your answer to this...

--
Menno

 
 
 

cron + script

Post by Claus Atzenbec » Sat, 21 Jul 2001 19:48:48


I found the solution: I needed to add "--daemon 0 -f /root/.fetchmailrc"
behind the fetchmail command.

Claus

Claus Atzenbeck wrote on Mittwoch, 18. Juli 2001 23:47:

Quote:> I wrote a little script which is supposed to dial into the internet, get +
> send my mail and log out again For this, I created the following entry in
> /etc/crontab:

> 30 7-23/3 * * * root    /usr/local/bin/mailXchange >
> /var/log/fetchmail.log

> When this script is started by crond, it is all done (almost) at the same
> time: dialin, fetchmail, sendmal, terminate session.

> When I start this script by command line, it is working well, e.g. it does
> not terminate the session before finishing fetchmail + sendmail.

> It seems that crond puts a "&" at the end of every line in that script.

> Here is the script:

> *****
> #!/bin/bash

> /etc/sysconfig/network-scripts/net_cnx_up > /dev/null
> sleep 2  # this line is necessary, because fetchmail would start
>           # before dialing is complete

> fetchmail
> sendmail -q -v

> /etc/sysconfig/network-scripts/net_cnx_down > /dev/null
> *****

> Any idea how to get this script working right with cron?

> Thanks a lot!
> Claus

 
 
 

1. cron script

what file do i edit for root? /var/cron/tabs/root ?

i left my script running for about 2 weeks.. i looked back.. and root had
18MB of mail from errors in the cron script...

how should i look? i currently have this..

*/5 * * * * root /usr/local/mrtg/run/mrtg /usr/local/mrtg/run/pm2e.cfg

i get email every 5 minutes saying.. root not found, pm2e.cfg not found..

can anyone help?
 -- david

2. Low-Level Centronics Parallel Port in UNIX

3. Cron script needed to make backups - help please

4. LPU 0.9-26 - The Label Printing Utiliy (update)

5. Cron script problem

6. Modeline or Accelerated-X config for Idek MF8617 ?

7. Problem with Cron script in mailserver

8. how to mount intrnal zip drive

9. Cron Script Problem

10. cron + scripts

11. Cron script to call funciton

12. CRON script for music

13. I was hacked, invisble directory .fz and cron script botck