How do I setup two cron jobs to run every night at 3:00 and 3:10?

Seth Spearman

I have an ubuntu home server running virtual box. I have virtual server running on that box that I am having problems with. For now I don't have time to troubleshoot the actual issue but I have found that restarting the server fixes the issue for at least 24 hours. So my quick fix is to restart the server each night.

Bottom line is that I want to run the following command at 3:00 am 7 days a week.

vboxmanage controlvm virtualpbx acpipowerbutton

at 3:05 each night I want to run the following command.

vboxmanage startvm virtualpbx -type headless

The best answer will give me step-by-step instructions for getting this done from launching the console to closing the console. I want to learn more of cron and the linux infrastructure but for now I don't have the time.

Thanks so much for your help.

Seth B Spearman

** EDIT **
I want to be able to put these in place from an ssh prompt. (Don't laugh but the server doesn't have a monitor hooked up right now and it would take a fair amount of work to get it working.). But I can ssh to it at any time.

From the ssh prompt crontab does not seem to work...it just goes to the next line and seems to be waiting for more input.

I tried to install crontab from ssh using sudo apt-get install crontab but it can't find it in any repository.

So I think I will use nano and do it manually but I need to know where to put it.

ALL that to say...I am doing this from an ssh prompt...which I think doesn't matter but thought I would let you know.

Seth

Eric Carvalho

Open a terminal (Ctrl+Alt+T) then run:

crontab -e

If it asks you to select an editor, choose nano. Insert these lines at the end of the file:

 0 3 * * * vboxmanage controlvm virtualpbx acpipowerbutton
 5 3 * * * vboxmanage startvm virtualpbx -type headless

Press Ctrl+O,Return to save the file and Ctrl+X to exit. Then run exit to close the terminal.

EDIT
This is what the OP did:

  1. ssh to server
  2. sudo nano /etc/crontab <key in password>
  3. edit per Eric's recommendation but added the username that starts the VMs as follows...

    0 3 * * * username vboxmanage controlvm virtualpbx acpipowerbutton   
    5 3 * * * username vboxmanage startvm virtualpbx -type headless  
    
  4. CTRL-X to close. Enter to save the crontab.

  5. Restart cron: sudo service cron stop then sudo service cron start.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I use systemd to replace cron jobs meant to run every five minutes?

How to setup CRON job to run every 10 seconds in Linux?

How do I run parallel jobs in python3 with asyncio?

How to set a cron job to run every 3 hours

How to run a cron jobs in every minute for a specific hour on server

How do I run a script every day at 00:00 hrs to hit an django API on Ubuntu machine?

How to instruct cron to execute a job in airflow Run every 3rd Jan, 3rd April, 3rd July, 3rd Oct at 11:00 AM UTC Time Zone

How to setup cron job to run every 5 days?

Run Cron job every 10 minutes between two hours

How to run CRON jobs on cPanel?

How do I combine these 3 SQL jobs into a single SSIS package?

drupal 7 How can I get cron jobs to run automatically

How do I make my Discord bot run a function every sunday at 0:00?

How do I make cron run something every "N"th minute, where n % 5 == 1?

How do I run a script for 1st working day of every month in cron?

Run 3 jobs sequantially

How to run cron job every one hour and 10 min

How to run a cron job every 10 seconds in ruby on rails

How to run method every night on JEE Cluster

node-cron run job every 3 hours

jenkins cron: run every 3rd minute, starting at 1

How do I list all cron jobs for all users?

How do I add/remove cron jobs by script?

How do I find every number with two 3s and two 7s in a list of 60501 numbers using VBA?

How run Codeigniter php function in controller using Cron Jobs every one hour via cPanel

Run Cronjob every night between 3-6 o clock but only once

Run script every 4 minutes but don't run from 3:00 to 3:40

How would I get a cron job to run every 30 minutes?

How do I split time periods by 5 minute breaks (00:00, 00:05, 00:10, ...)?