Results 1 to 6 of 6

Thread: crontab - help with advanced settings

  1. #1
    Join Date
    Apr 2006
    Location
    Leeds, England
    Beans
    177
    Distro
    Ubuntu 16.04 Xenial Xerus

    crontab - help with advanced settings

    Hi Guys,

    I am having trouble finding the correct syntax to create a cronjob that will run every 6 weeks (or 8 times a year). Even better if this will run on a Monday, but not essential.

    I can't quite work this one out. It would be nice if @yearly/8 worked, but it doesn't.

    Any help would be greatly appreciated.
    The Ubuntu Counter Project - User number # 6435

  2. #2
    Join Date
    Aug 2006
    Beans
    13,354
    Distro
    Ubuntu Mate 20.04 Focal Fossa

    Re: crontab - help with advanced settings

    I am not a cron expert, but it seems that this particular task would be easier to accomplish with 8 separate cron jobs.

  3. #3
    Join Date
    Apr 2006
    Location
    Leeds, England
    Beans
    177
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: crontab - help with advanced settings

    I was hoping you wouldn't say that.. I have about 30 jobs to create on a 6 week rota..

    That would mean 240 cron jobs!

    Any other suggstions anyone?
    The Ubuntu Counter Project - User number # 6435

  4. #4
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: crontab - help with advanced settings

    I don't think there is any way to have it run every 6 weeks. You can do it monthly, but if you wanted to do it every 6 weeks, I don't think that's possible.

    Well unless you wanted to hack it with a script that sleeps for 2 weeks.. but that may cause more problems then not. Set cron to run a script in 4 weeks, and have a command to let the script sleep for 2 weeks. Nasty hack but it might be better then setting 30 + cronjobs a week.

    Anyhow, if the jobs are predefined, you can just import them into cron at scheduled intervals, worth a shot I guess.

    Anyhow, you can replace the current crontab with a file by running this:

    Code:
    crontab -u username somefile
    See here for some more infos.
    Last edited by CharlesA; November 10th, 2011 at 01:29 PM. Reason: added linjk
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  5. #5
    Join Date
    May 2010
    Location
    uk
    Beans
    9,249
    Distro
    Xubuntu 14.04 Trusty Tahr

    Re: crontab - help with advanced settings

    Hi

    Here's another idea.

    If this is a server that is not often rebooted then what about scheduling it using the at command.

    The script you run could schedule another run for itself by calculating the date in 6 weeks time.

    This could be abstracted into a script that calls your main worker script.

    You could hook it into cron using the @reboot option. Rescheduling after a reboot could be handled by storing the date it needs to run in a file and using that to pass to the at command again.

    I have not attempted this and i don't know if it's feasible so maybe someone like Charles could comment on it as i would not want to lead you up the proverbial garden path

    Kind regards
    If you believe everything you read, you better not read. ~ Japanese Proverb

    If you don't read the newspaper, you're uninformed. If you read the newspaper, you're mis-informed. - Mark Twain

    Thinking about becoming an Ubuntu Member?

  6. #6
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: crontab - help with advanced settings

    Quote Originally Posted by matt_symes View Post
    Hi

    Here's another idea.

    If this is a server that is not often rebooted then what about scheduling it using the at command.

    The script you run could schedule another run for itself by calculating the date in 6 weeks time.

    This could be abstracted into a script that calls your main worker script.
    That's actually a good idea. I have used @reboot scripts before, but not in that matter.

    My idea was to have a script wait 2 weeks and then run, but that might work too.
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •