Re : How to create this cron job?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Re : How to create this cron job?
# 1  
Old 12-09-2008
Re : How to create this cron job?

Hello All,

Hope this finds you well. I am creating this shell script that will create cron jobs in crontab file. What I am provided with is the start time , intervals and # of trials. Based of Start time ( say 7:15 am ) and interval being 15 minutes, # of trial being 5 , I should create cron job with following time ...

07:15 07:30 07:45 08:00 08:15

now I would create cron job for this time requirement as ...

15,30,45,00 07,08 * * * command.....

But above would also run command at 07:00 , 08:30, 08:45 ....which is not required. I am using Bourne Shell (sh) . Would appreciate your help in this regards. Let me know if I missed on some.

Thanks,
Sam
# 2  
Old 12-09-2008
create the cron job with two lines :

15,30,45 07 * * * command.....
00,15 08 * * * command.....
# 3  
Old 12-09-2008
Quote:
Originally Posted by ThobiasVakayil
create the cron job with two lines :

15,30,45 07 * * * command.....
00,15 08 * * * command.....
Hello ThobiasVakayil,

So besides spliting them into 2 lines, there is not other solution ....is this correct ?

Thanks,
Sam
# 4  
Old 12-09-2008
I think it is the solution.
B'cos there is no match between the minutes entry.
# 5  
Old 12-09-2008
Its not possible in any way.
In single line we cant give the timings.
need to put in different lines for each execution on the same field(*).
# 6  
Old 12-09-2008
Quote:
Originally Posted by samshaw
So besides spliting them into 2 lines, there is not other solution ....is this correct ?
If you insist on having one line only in cron you could create an intermediary script which starts your job at the correct times using the "at"-command. This script could be invoked by cron. Crontab would look like this:

Code:
15 7 * * * * my_startscript.sh

and my_startscript.sh would look like this:

Code:
#!/bin/sh

echo "/my/app -options" | at now
echo "/my/app -options" | at now + 15 minutes
echo "/my/app -options" | at now + 30 minutes
echo "/my/app -options" | at now + 45 minutes

exit 0


I hope this helps.

bakunin
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cron job - Need to run Cron every quarter at particular time

Hi, 1) If some job supposed to run on 1st of every month at 7 AM In cron job when we have a blackout on the 1st ( i.e when 1st falls on a sunday ) how can we make the job run the next business day? 2) How can we run a job on 25th of every quarter 7 AM(jan,apr,jul,oct) And if 25th... (5 Replies)
Discussion started by: System Admin 77
5 Replies

2. UNIX for Dummies Questions & Answers

Create cron job without root

Hi there, I need to create a crone job to backup certain files on my disk without root permissions. Also if I will be able to edit cronetab then I need to know how to edit it with any editor other than vim :mad: (5 Replies)
Discussion started by: aelhosiny
5 Replies

3. UNIX for Dummies Questions & Answers

Need help to create cron job

Dear Experts, I want to create cronjob with the following steps: 1. go to directory /home/logs/ $cd /home/logs/ 2. copy to /tmp/ the most recent file with "prefix" local_data_ and sufix ".gz" ls -ltr drwxr-xr- 4096 Nov 24 2009 bak drwxr-xr-x 24096 Aug... (6 Replies)
Discussion started by: maxsub
6 Replies

4. 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

5. Shell Programming and Scripting

How to create a cron job to take an uploaded filename and move it?

OK, So complete newbie here. I would normally do this in PHP or through my FTP program script but I can't in this case (the files are not coming from me, coming from a third party FTP upload). I have an FTP server (Linux) accepting files coming in from a standard FTP program. Each file... (2 Replies)
Discussion started by: bull_frog
2 Replies

6. Shell Programming and Scripting

Im trying to create a FTP Cron Job

Hello, Im fairly new to this and am hoping for your help in moving forward. 1. I need to carry out a FTP transfer from SERVER1 to SERVER2 at 3am every morning. 2. The FTP is to work on SERVER1 3. There will be many files to transfer (96 files per day) 4. I want to delete the files... (3 Replies)
Discussion started by: nozerf
3 Replies

7. Solaris

cron job starts new cron proccess

I run cron in solaris 10 zone. One cron job which syncing files to nfs mounted on container, creates after finishing another cron proccess(/usr/sbin/cron), and after 100 existing cron proccesses next cron job will not start. It's too weird for me, I'm not able to solve this problem. Theoretically... (3 Replies)
Discussion started by: ron76
3 Replies

8. Shell Programming and Scripting

create a chmod cron job help please

hi all, I'm so embarrasingly new; apologies. So here's my dilemma; files are being uploaded to the server via a php script... this is therefore assigning ownership to 'nobody' rather than the account 'user'. It's screwing with the permissions and then the owner can't ftp download images... (2 Replies)
Discussion started by: sirj
2 Replies

9. HP-UX

How to create a cron job and run in quality system

Hi Experts, I'm a SAP Basis, I have a small doubt would request you please help on this... 1. I wold like to copy files from one system to another system? as per my knowledge "we have to mount the prod filesystem on the quality box and do a copy every day thru crontab script, or do it via... (2 Replies)
Discussion started by: mahantysk
2 Replies

10. Shell Programming and Scripting

How to create cron job automatically?

How do I write a perl script to get the cron jobs? I could do a perl -e ' system "crontab -l > jobs.txt " '; Is there a better way? Then I can use perl to make changes to jobs.txt. How can I submit the changes. I suppose I could use system "crontab jobs.txt", is there a better way? ... (0 Replies)
Discussion started by: siegfried
0 Replies
Login or Register to Ask a Question