Linux script for several cronjob


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux script for several cronjob
# 1  
Old 03-02-2015
Linux script for several cronjob

I have a linux server for my joomla website. I am importing xml feeds (around 200). The component give a tool which list all the cron job commands to automaticaly make the feeds import

I don't want to add one by one each cron job.

So my idea is to make one cron job which will call a shell script command. Inside this script I will put all these commands.

Problem1: I have to make the import one by one. So the shell script should look like

Code:
/usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=2
wait... until import is finished...
/usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=3 wait... until import is finished... etc...

But I guess we cannot know when import is finished? In this case we will wait a few minutes?

Problem 2: I have 200 feeds to import. If for example I run the cron job once per week and the cron job from previous week is not finished... Then I'll have 2 cron jobs running and this could use all the ressource of server... And it will be down. So I had the idea to put a line of code which will write a value in a indicator.txt file.

If inside indicator.txt file, there is line: cronjob_finished = true Then cron job can start

If inside indicator.txt file, there is line: cronjob_finished = false Then cron job cannot start

As a resume, the code should look like this:

Code:
#!/bin/sh
# This is some secure program that uses security.

# read indicator.txt

if cronjob_finished = false then
    STOP THE SCRIPT
else
    let's start the script
    /usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=2
    wait... until import is finished... OR ... wait a few minutes...
    /usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=3
    wait... until import is finished... OR ... wait a few minutes...
    /usr/bin/php /home/website/public_html/superf/cli/com_cmdealaggregator_import_cron.php --id=4
    wait... until import is finished... OR ... wait a few minutes...
    etc.......
    write in indicator.txt, cronjob_finished = true

fi

Is there any expert who will accept to help me please?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script with cronjob

Hello All, I have a script which will cd into a directory based on current timestamp. It will then do a grep and search for a condition. It's run on a cron job that runs every 30 minutes. So if it finds a match in 00, it sends out the contents of that grep to an alert and emails out. Now... (3 Replies)
Discussion started by: liketheshell
3 Replies

2. UNIX for Dummies Questions & Answers

Alias script which runs with cronjob

Hi, I wrote a alias script and I want to run this script every day at 10 AM. I don't want to mention this alias command in .profile(Since alias commands are nearly 30 to use). so when I'm trying to call script with cronjob its not running, any help on this. the script looks like : ... (2 Replies)
Discussion started by: rockingvj
2 Replies

3. AIX

SH Script Execution Problems with Cronjob

Hi, I have created a sh script to startup and shutdown the oracle database, when I execute the script thru command line it execute successfully, but when I call the script thru cronjob it does not execute. The scripts are as follows: LOG=/oracle/times.log export ORACLE_SID=prod echo... (6 Replies)
Discussion started by: lodhi1978
6 Replies

4. UNIX for Dummies Questions & Answers

Script not running through Cronjob

Hi, I have a .ksh script which updates the database. The script is running fine manually but it is not running through cron.All the file permissions are fine. The script contents are as below: #!/usr/bin/ksh ddate=`date +%Y%m%d` echo $ddate nohup sqlplus crm/crm @db_state_sync.sql >>... (3 Replies)
Discussion started by: shivangi
3 Replies

5. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

6. Shell Programming and Scripting

issue while configuring a script in the cronjob

Hi all, I have written the following script which will try pinging to almost 24 nodes and when the connectivity is down it sends me an alert saying the node is down. It also gets me a trace route information and a contact information. When i run this script manually it actually works. But... (3 Replies)
Discussion started by: venkidhadha
3 Replies

7. Solaris

Creating a CronJob Script

Hi All, Good Day. Anyone can guide me on how to create a cronjob script that run prstat -a and vmstat 10 10 on the certain time of the day and produce a log which will be kept in a specific directory? I am running on Solaris 10. Thanks. (2 Replies)
Discussion started by: ronny_nch
2 Replies

8. Shell Programming and Scripting

cronjob: Partial script error

Part of my script throws an error. Your "cron" job on mitv-t-voms02 /usr/tlrscr/runhc.sh produced the following output: /usr/tlrscr/runhc.sh: top: not found /usr/tlrscr/runhc.sh: top: not found /usr/tlrscr/runhc.sh: top: not found syntax error on line 1, teletype That part of... (2 Replies)
Discussion started by: sundar63
2 Replies

9. Shell Programming and Scripting

cronjob inside the script

Hiii, can nayone provide me the sample script which can do the following tasks--- I will apperciate if anyone give me their valuable inputs.I guess this is not at all a big task for the experts in the forum so kindly help me out in this. (3 Replies)
Discussion started by: namishtiwari
3 Replies

10. Shell Programming and Scripting

help help cronjob problem with script

hi all, have no experience with cronjob at solaris, i have create script like below: #!/bin/sh DAY=`/export/home/oracle/bin/lastdate | nawk '{print $1}'` /export/home/orahome/bin/sqlplus -s abc/abc<<eof set heading off; set linesize 100; set feedback off; spool... (4 Replies)
Discussion started by: bucci
4 Replies
Login or Register to Ask a Question