Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

setting a one off cron job in crontab

Posted on 2006-06-23
8
Medium Priority
?
400 Views
Last Modified: 2012-06-21
Hi

I want to set up a cron job to run once at 7.45pm on Sunday. Is this setting correct?

45 19 25 6 0 /opt/utils/sendMesg.sh

Thanks

Joe
0
Comment
Question by:joe1976
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 16

Expert Comment

by:xDamox
ID: 16967872
Hi,

The above will run at 7:45PM on the 25 of the month June you could change it to the following:

45  19  0  0  0  /opt/utils/sendMesg.sh

The above should run at 7:45PM every sunday
0
 
LVL 16

Expert Comment

by:xDamox
ID: 16967884
Opps I should of put:

45  19  *  *  0  /opt/utils/sendMesg.sh
0
 

Author Comment

by:joe1976
ID: 16967932
Thanks for the quick reply. I'm sure I read somewhere that the 3 and 5th fields are OR'd, so would your solution not run tomorrow night at 7.45pm as well?
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 4

Expert Comment

by:JulieBouillon
ID: 16968005
If you want to run the job only one time, you should use the "at" command.
Only use cron if you want your job to run more than once (eg. each 25th of month, each day at 1 am, ...)
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 16968118
As mentioned by JulieBouillon, you should use 'at' if this is a one off command. cron is for repeated tasks.

at -f mytask 18:30

Will run the tasks in the file "mytask" at 18:30

Tasks need to be 1 per line in the mytask file.

You will probably need to create the file:

/etc/at.allow

and add your username to it if you want to run 'at' as any user other than root.

man at

is worth a read if you wish to be able to examine tasks in the 'at' queue.

(   (()
(`-' _\
 ''  ''

0
 
LVL 22

Accepted Solution

by:
pjedmond earned 2000 total points
ID: 16968174
Best I read the question properly!

at -f mycommand 19:45 25/06/06

Where the file mycommand is:

---------------8X-----------------
/opt/utils/sendMesg.sh
---------------8X-----------------

45 19 25 6 0 /opt/utils/sendMesg.sh

in the crontab will sendMesg.sh this year at 19:45 on 25 Jun, and also 19:45 on 25 Jun next year, the year after and so on. I guess if you don't have access to the 'at' command due to /etc/at.allow permission not allowing you to use it then your approach is fine. Just remember to remove the crontab entry after you've used it:)

(   (()
(`-' _\
 ''  ''
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 16968194
>in the crontab will sendMesg.sh this year at 19:45 on 25 Jun, and also 19:45 on 25 Jun next year, the year after and so on.

Ooops - slight mistake -- It will only run in a year where 25 Jun is a Sunday! Change the 0 to a * for every year!

http://www.adminschoice.com/docs/crontab.htm#Crontab%20file

for crontab syntax.

(   (()
(`-' _\
 ''  ''
0
 
LVL 16

Expert Comment

by:xDamox
ID: 16968313
Hi joel1976,

*     *   *   *    *  command to be executed
-     -    -    -    -
|     |     |     |     |
|     |     |     |     +----- day of week (0 - 6) (Sunday=0)
|     |     |     +------- month (1 - 12)
|     |     +--------- day of month (1 - 31)
|     +----------- hour (0 - 23)
+------------- min (0 - 59)

0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question