LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 01-07-2014, 03:32 PM   #1
KroniK
LQ Newbie
 
Registered: Aug 2012
Posts: 13

Rep: Reputation: Disabled
cron not executing a script


Hello, I have been working with Linux for several years and this is a first for me. For some reason cron is not executing a script for me.

I have been editing the crontab via the command "crontab -e" as the root user.

crontab:
Code:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin

00 10 * * * root /backup2/kiska.rsync-incremental-backup.sh
I have included an extra line after the end of the crontab in case that newline issue was causing problems, but nothing has changed.

I have verified that crond is running:
Code:
# ps -aux | grep cron
root      8501  0.0  0.0   5988   740 ?        Ss    2013   0:09 /usr/sbin/crond -n
and here is the systemctl output:
Code:
# systemctl status crond
crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled)
   Active: active (running) since Mon 2013-12-30 16:35:08 AKST; 1 weeks 0 days ago
 Main PID: 8501 (crond)
   CGroup: name=systemd:/system/crond.service
           └─8501 /usr/sbin/crond -n

Dec 30 16:35:08 Atka crond[8501]: (CRON) INFO (running with inotify support)
Dec 30 16:35:08 Atka crond[8501]: (CRON) INFO (@reboot jobs will be run at co....)
Jan 06 10:56:01 Atka crond[8501]: (root) RELOAD (/var/spool/cron/root)
Jan 06 11:12:01 Atka crond[8501]: (odroid) RELOAD (/var/spool/cron/odroid)
Jan 06 11:18:01 Atka crond[8501]: (root) RELOAD (/var/spool/cron/root)
Jan 06 11:21:01 Atka crond[8501]: (root) RELOAD (/var/spool/cron/root)
Jan 06 11:25:01 Atka crond[8501]: (root) RELOAD (/var/spool/cron/root)
Jan 07 09:12:01 Atka crond[8501]: (root) RELOAD (/var/spool/cron/root)
Jan 07 09:13:01 Atka crond[8501]: (root) RELOAD (/var/spool/cron/root)
Jan 07 09:18:01 Atka crond[8501]: (root) RELOAD (/var/spool/cron/root)

Any help would be appreciated.
 
Old 01-07-2014, 07:18 PM   #2
Habitual
LQ 5k Club
 
Registered: Jan 2011
Location: Nowhere near you, thank God.
Distribution: High Sierra
Posts: 8,598
Blog Entries: 15

Rep: Reputation: Disabled
Code:
ls -al /backup2/kiska.rsync-incremental-backup.sh
output and does that file have "#!/bin/bash" in it?
 
Old 01-07-2014, 08:00 PM   #3
KroniK
LQ Newbie
 
Registered: Aug 2012
Posts: 13

Original Poster
Rep: Reputation: Disabled
Yes the code starts with #!/bin/bash

and:

Code:
# ls -al /backup2/kiska.rsync-incremental-backup.sh
-rwxr-xr-x 1 root root 8410 Jan  7 09:13 /backup2/kiska.rsync-incremental-backup.sh
 
Old 01-07-2014, 08:02 PM   #4
Habitual
LQ 5k Club
 
Registered: Jan 2011
Location: Nowhere near you, thank God.
Distribution: High Sierra
Posts: 8,598
Blog Entries: 15

Rep: Reputation: Disabled
what do the /var/log/* files "say" if anything happened?
Code:
grep -i  backup /var/log/* -R
You know this stuff, yes?

Does it run manually?
absolute /path/to/rsync in kiska.rsync-incremental-backup.sh ?

Just thinking out loud...
 
Old 01-07-2014, 09:26 PM   #5
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 4,728

Rep: Reputation: 754Reputation: 754Reputation: 754Reputation: 754Reputation: 754Reputation: 754Reputation: 754
When you used crontab -e you edited the root user crontab. It is root's, but it is still a user's crontab. In a user's crontab you cannot specify the user for which the crontab has to run. So it seems the line is an invalid syntax.

If you want to run a job with the user specified, you have to use /etc/crontab. This file is edited directly, and cron detects any changes.

I think this /etc/crontab is the preferred way for system-wide jobs.

Unless you set some options somewhere, cron does not report syntax failures but dies silently.

jlinkels
 
  


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
[SOLVED] cron in debian is not executing a script at the scheduled time educated__fool Linux - Newbie 8 09-20-2012 02:37 AM
Bash script run via cron not executing MYSQL command mackstar Linux - Server 4 04-23-2009 06:01 AM
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 09:16 AM
cron not executing yusufs Linux - Newbie 38 12-27-2007 06:01 PM
Cron not Executing PHP script Badnoodles Linux - General 2 10-25-2006 05:56 PM

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

All times are GMT -5. The time now is 09:02 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration