LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 09-14-2013, 10:26 PM   #1
JockVSJock
Member
 
Registered: Jan 2004
Posts: 602

Rep: Reputation: 31
Cron Job Error Show the Following 24: bad minute


Currently running Ubuntu 12.04 LTS 64-bit with 3.5.0-28-generic for the kernel. This is all as a guest in VirtualBox 4.2.18.

I'm trying to setup a cronjob thru crontab under root account and continue to get the following error when trying to save it.

The goal of the cronjob is to run apt-get commands to update the system without me having to do anything.

Here is the error message

Code:
 
"/tmp/crontab.iuvXOC/crontab":24: bad minute
errors in crontab file, can't install.
Here is the cronjob

Code:
00 20 * * * root (apt-get update && apt-get -y -d upgrade) > /var/log/aptupdate.log

apt-get clean
>/dev/null 2>&1
I found this example to test the syntax for cron and here is the output from that
Code:
root@ubuntu64vm:/var/log# cat -v /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 6	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
By chance, the syntax color changes to green if I replace the leading zero from 0 to :

However when I try to back out of vim, I still get the same error message.
 
Old 09-15-2013, 02:05 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Quote:
Originally Posted by JockVSJock View Post
Here is the error message

Code:
 
"/tmp/crontab.iuvXOC/crontab":24: bad minute
errors in crontab file, can't install.
Here is the cronjob

Code:
00 20 * * * root (apt-get update && apt-get -y -d upgrade) > /var/log/aptupdate.log

apt-get clean
>/dev/null 2>&1
All the entries in cron need to be a single line and need to start with a time indicator. The only exception is the (possible) header, which may contain environment information (PATH=, SHELL= etc).

The bold part in the above is not legal and that were the error comes from.

Have a look at this:
Code:
00 20 * * * root (apt-get update && apt-get -y -d upgrade) > /var/log/aptupdate.log ; apt-get clean >/dev/null 2>&1
Unless the command is rather simple, I personally don't like using (complicated) one-lines in cron. The long lines become unreadable, some characters need to be escaped (they are special seen from cron's perspective) and environment settings are harder to manipulate.

When the entry becomes more complicated I tend to create a script and call that script from cron.
 
Old 09-15-2013, 01:57 PM   #3
JockVSJock
Member
 
Registered: Jan 2004
Posts: 602

Original Poster
Rep: Reputation: 31
Putting it all on one line fixed it.

thanks
 
  


Reply

Tags
cron, crontab, ubuntu 12.04


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem is (bad minute) error annotate Linux - Server 15 01-23-2014 05:41 PM
Help me on Cron job error mhrlive Linux - Server 9 09-27-2012 06:31 AM
[SOLVED] Configured Cron job executed every hour is instead executed every minute for 10m markings Linux - Software 4 05-13-2012 05:43 PM
bad minute error adding a crontab job htamayo Linux - Newbie 7 03-15-2010 08:56 AM
Cron job error gocool_fedora Linux - Software 2 12-22-2008 11:50 AM


All times are GMT -5. The time now is 02:34 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration