Avatar of Eric Donaldson
Eric Donaldson

asked on 

Cron jobs

Hi,

I am trying to figure out cronjobs setup on a linux server.  When i do crontab -u -l , some output displays.  Some jobs have a # in front of them but 1 last job has 0 22 ** 1-5/directory/ cache, etc.

How can I stop all jobs for the 5th ?

Thanks
LinuxLinux NetworkingLinux OS Dev

Avatar of undefined
Last Comment
Gerwin Jansen
ASKER CERTIFIED SOLUTION
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Eric Donaldson
Eric Donaldson

ASKER

sorry, I mean for just 1 day
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

you mean to stop job for one day ? then comment the line with #

If you mean a particular day of the week or month then you can exclude from range
Avatar of Eric Donaldson

ASKER

stop for just 1 day;  how can I remove it from this line?

0 22 * * 1-4 /directory/ cache

take out Aug 5th from running
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

there is no straight way. In your script, you can always at the beginning check for date 5 Aug and don't run script.
SOLUTION
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

That 1-5 is referring to day of week numbers, where 0=sunday, 1=monday etc.

So if you want to stop all jobs for a certain date, you have to determine the day of week number for that certain date and then adapt the 1-5 to 1-4 for your case (it is a coincidence that Aug 5th is a Friday so day number 5).

A different approach is that you disable the crontab for a user completely by removing the crontab entries and restoring them the next day.

To save entries: crontab -l > your_crontab_file

To remove entries: crontab -r

To restore entries: crontab your_crontab_file

Be sure to check contents of file your_crontab_file before using -r or you'll loose your entries.
SOLUTION
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

@Omar - No, author is posting:

0 22 * * 1-5

so 1-5 is the fifth field.
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Eric, any update? Need further assistance?
Avatar of omarfarid
omarfarid
Flag of United Arab Emirates image

@Gerwin, I thought your comment was about my last post where I recommended to have two crontab jobs:

https://www.experts-exchange.com/questions/28961468/Cron-jobs.html?anchorAnswerId=41742674#a41742674
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

@Omar, no it wasn't ;) My suggestion would be to disable crontab for the day and enable again. Not sure if we get a response though since Aug 5th was a week ago...
Linux
Linux

Linux is a UNIX-like open source operating system with hundreds of distinct distributions, including: Fedora, openSUSE, Ubuntu, Debian, Slackware, Gentoo, CentOS, and Arch Linux. Linux is generally associated with web and database servers, but has become popular in many niche industries and applications.

71K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo