Can you please help me to create a script considering follwoing points.

Step 1:

First stop all existing cronjob (at 5 PM) which are running by using #

Step 2:

After that delete some files

Step 3:

Then again start all existing cronjob (by removing #)

Thank you.

closed as unclear what you're asking by dhag, Rui F Ribeiro, Jeff Schaller, Archemar, GAD3R Feb 26 '17 at 13:03

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Why don't you instead just stop cron while you do your maintenance? Note that this is not a script writing service and you are expected to show what you tried and where you got stuck. Doing such a script would be quite easy, but also very pointless. – Julie Pelletier Feb 26 '17 at 6:23
  • Yes I know. But need to do this everyday. that's why, i need a script. – Wasila Feb 26 '17 at 6:28
  • 2
    You can do a script that would stop and restart cron. Not sure what your point is but it sounds like bad planning any way I look at it. Not running a cron job can have some impact depending on what it does. – Julie Pelletier Feb 26 '17 at 7:26
  • thanks. yes i need a script that would stop and restart cron. Can you help me to share that script – Wasila Feb 26 '17 at 7:41
  • I think you do not understand how cron works...cron is used to define time for tasks. There is no use is stopping or starting it. – Rui F Ribeiro Feb 26 '17 at 8:48

Julies simple solution, stopping and restarting the service as script (Debian Linux):

service cron stop
service cron start

Or delete the crontab temporary:

crontab -l > cronsafe
crontab -r
crontab cronsafe

Approach for short interrupts; send a STOP signal to cron and resume with CONT, like

killall -STOP cron
killall -CONT cron

Not the answer you're looking for? Browse other questions tagged or ask your own question.