LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-20-2012, 08:57 AM   #1
yousefzad
LQ Newbie
 
Registered: May 2012
Posts: 14

Rep: Reputation: Disabled
Suspend cron for certain days


Cron jobs are running everyday at 8PM to hot backup database, archivelog, and some other files.

Sometimes crontab scheduled backups need to be suspended for some other tasks randomly but doesn't happen all the time.

Objective:
I need to create simple script or command ( example : stop_cron, start_cron) that will suspend cronjob for that particular day.

thanks,
 
Old 09-20-2012, 08:04 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
As the second line of your cron job just add:
Code:
[ -e "/etc/nocronjob" ] && exit 0
then touch "/etc/nocronjob".

Of course you'll be responsible for removing "/etc/nocronjob" when it's OK to run the job again.


*And BTW: don't use cron. Use 'at' ;-p
 
Old 09-20-2012, 11:14 PM   #3
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
I'm curious; Yousetzad, as I'm learning shell scripting for the purpose of cron jobs to run-
http://www.ceri.memphis.edu/computer...hell_help.html

After you made the shell script for all of you cron jobs to run; how did you make it executable?
 
Old 09-22-2012, 08:02 AM   #4
yousefzad
LQ Newbie
 
Registered: May 2012
Posts: 14

Original Poster
Rep: Reputation: Disabled
hi,

while i am using at command " at 15:30 /sbin/poweroff" face to the problem which says: syntax error .Last token seen: /


what is this and how can i rectify this.

thanks.
 
Old 09-22-2012, 11:30 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by yousefzad View Post
how can i rectify this.
Two things: 0) 'man at' for examples of how to specify time and 1) 'man shutdown' for a list of args including poweroff and specifying when (meaning time) to power off. IOW you wouldn't need 'at' but you do need root rights.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Cron directories: /var/spool/cron/cron.GfqqGO Woodsman Slackware 4 05-11-2011 02:37 PM
Cron backup script stops running after a few days brokenpromises Linux - Server 5 04-05-2008 05:30 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron job and apm suspend linuxhippy Slackware 7 01-20-2007 06:43 AM
windows system suspend returned my data partition to 3 days ago cesine Linux - General 6 03-28-2006 10:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration