script per cronjob executed several times
Hi there,
I made a script for copy files to an directory. It looks like: Code:
date=`date +%F` |
What is the cron job line? There is nothing in the script to create 50 instances so it must be the cron job that does so.
|
Hi,
the Cronjob looks like this: * 23 * * * /root/script/backup.sh |
after the cronjob started, it looks like:
Code:
root@server:~# ps aux | grep backup |
Puzzling. Do those processes have children?
|
I would make a pid file (script creates and removes at the end).
When it exists script will do nothing, just exit. also you can add set -xv and redirect output (and stderr) to a logfile to see what's happening |
Quote:
This will run your job once. 00 23 * * * /root/script/backup.sh |
Quote:
Code:
# Check and write PID file |
This doesn't cover every aspect but stops the script in one instead of seventeen lines ;-p :
Code:
[ $(pgrep -f /root/script/backup.sh|head -1) -eq $$ ] || { logger "Already running, exiting."; exit 0; } |
Quote:
We have a winner Although making/checking a PID is a good idea as well. |
Hi,
merci for those good answers! :-) Thank you very much! :D |
All times are GMT -5. The time now is 08:00 PM. |