LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cron not executing a script (https://www.linuxquestions.org/questions/linux-newbie-8/cron-not-executing-a-script-4175490457/)

KroniK 01-07-2014 02:32 PM

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.

Habitual 01-07-2014 06:18 PM

Code:

ls -al /backup2/kiska.rsync-incremental-backup.sh
output and does that file have "#!/bin/bash" in it?

KroniK 01-07-2014 07:00 PM

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


Habitual 01-07-2014 07:02 PM

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...

jlinkels 01-07-2014 08:26 PM

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


All times are GMT -5. The time now is 11:44 AM.