Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backintime root crontab doesn't run (missinng line-feed 0x0A on last line bug) #781

Closed
dtschmitz opened this issue Jun 18, 2017 · 8 comments
Labels
Scheduling cron, anacron etc.
Milestone

Comments

@dtschmitz
Copy link

dtschmitz commented Jun 18, 2017

Thank you for all the great work you do.

I have reinstalled Arch and cronie with backintime, enabled cronie and started the service from systemctl, status:

[root@ThinkPad backintime]# systemctl status cronie
● cronie.service - Periodic Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/cronie.service; enabled; vendor prese
   Active: active (running) since Sun 2017-06-18 10:15:42 EDT; 10min ago
 Main PID: 5091 (crond)
    Tasks: 1 (limit: 4915)
   CGroup: /system.slice/cronie.service
           └─5091 /usr/bin/crond -n

Jun 18 10:15:42 ThinkPad systemd[1]: Started Periodic Command Scheduler.
Jun 18 10:15:42 ThinkPad crond[5091]: (CRON) INFO (Syslog will be used instead o
Jun 18 10:15:42 ThinkPad crond[509[root@ThinkPad backintime]# crontab -l
  30 8 *   *   *   /usr/bin/nice -n19 /usr/bin/ionice -c2 -n7 /usr/bin/backintime backup-job > /root/.local/share/backintime/`echo $(date +"%Y%m%d%H%M").cron.log` 2>&1
1]: (CRON) INFO (RANDOM_DELAY will be scaled w
Jun 18 10:15:42 ThinkPad crond[5091]: (CRON) INFO (running with inotify support)
Jun 18 10:15:42 ThinkPad crond[5091]: (CRON) INFO (@reboot jobs will be run at c
Jun 18 10:18:01 ThinkPad crond[5091]: (root) RELOAD (/var/spool/cron/root)

The root crontab:

[root@ThinkPad backintime]# crontab -l
  30 8 *   *   *   /usr/bin/nice -n19 /usr/bin/ionice -c2 -n7 /usr/bin/backintime backup-job > /root/.local/share/backintime/`echo $(date +"%Y%m%d%H%M").cron.log` 2>&1

If I try to run with a specific time to test (above last test @ 8:30am) the cron doesn't run.
Yet, if I copy paste the command to the root command line, it does run.
I have no issue with backintime -- has always run like a Swiss Watch.

What am I missing? Any help would be appreciated.
Kindest Regards,
Dietrich

P.S. I am running Antergos (Arch Linux) rolling release

@Germar
Copy link
Member

Germar commented Jun 18, 2017

Did you try without the > /root/.local/share/backintime/'echo $(date +"%Y%m%d%H%M").cron.log' 2>&1 part? Just to eliminate potential errors!?

cronie should log into syslog about starting and finishing jobs. Please search your syslog for infos about that job

@dtschmitz
Copy link
Author

dtschmitz commented Jun 18, 2017

Here's the output:

[root@ThinkPad backintime]# pwd
/root/.local/share/backintime
[root@ThinkPad backintime]# 

[root@ThinkPad backintime]# ls -l
total 1208
-rw-r--r-- 1 root root     588 Jun 18 09:53 18-06-2017.cron.log
-rw-r--r-- 1 root root     588 Jun 18 10:18 201706181017.cron.log
-rw-r--r-- 1 root root     588 Jun 18 10:20 201706181019.cron.log
drwxr-xr-x 2 root root    4096 Jun 17 06:17 anacron
-rw------- 1 root root      49 Jun 18 10:20 cron_env
drwxr-xr-x 2 root root    4096 Jun 16 21:52 mnt
drwx------ 2 root root    4096 Jun 18 10:20 password_cache
-rw-r--r-- 1 root root   15918 Jun 17 17:38 restore_.log
-rw-rw-rw- 1 root root 1190101 Jun 18 10:20 takesnapshot_.log
[root@ThinkPad backintime]# cat 201706181019.cron.log

Back In Time
Version: 1.1.20

Back In Time comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type `backintime --license' for details.

INFO: Lock
INFO: Take a new snapshot. Profile: 1 Main profile
INFO: Compare with old snapshot: 20170618-101728-861
INFO: Create hard-links
INFO: Call rsync to take the snapshot
INFO: Save config file
INFO: Save permissions
INFO: Create info file
INFO: Remove backups older than: 20170417-000000
INFO: Keep min free disk space: 1024 MiB
INFO: Keep min 2% free inodes
INFO: Unlock
[root@ThinkPad backintime]# 

It's working fine from the command line.
Thank you Germar. :)

@Germar
Copy link
Member

Germar commented Jun 18, 2017

Okay, it works fine on the shell. But cron can be a bit picky. So please remove that trailing part from your cron job and try again. Also please post the output of:

grep -i "cron" /var/log/syslog

@dtschmitz
Copy link
Author

I am using Arch which is systemd based. Is there a syslog in that case?
Otherwise I open journalctl and search and find:
un 18 06:32:01 ThinkPad crond[19912]: (root) CAN'T OPEN (/etc/crontab): No such file or directory

Since seeing that in systemctl status cronie I ran:
#touch /etc/crontab
There are no other errors.

@Germar
Copy link
Member

Germar commented Jun 18, 2017

So this seems to be a problem with cronie. Sorry, but I've no clue about systemd and cronie. Please ask in an Arch forum for help on getting cronie set up.

@dtschmitz
Copy link
Author

ok will do. Thanks

@dtschmitz
Copy link
Author

Here's the solution:
https://forum.antergos.com/topic/7231/root-crontab-cronie-backup-job-doesn-t-start/2#
I would suggest that you update your code the creates the crontab entry and append a line-feed (0x0A) to the end of the last line.
Story on Stackexchange

I had the same problem - a working crontab suddenly stopped after I added a new entry at the end. It turned out that I had forgotten to put a newline after that last line.

I found out by issuing the command

cat /var/log/syslog | grep crontab
and the output showed the problem:

Jul 2 08:16:01 shiva cron[1254]: (system) RELOAD (/etc/crontab)
Jul 2 08:16:01 shiva cron[1254]: (system) ERROR (Missing newline before EOF, this crontab file will be ignored)

@dtschmitz dtschmitz reopened this Jun 19, 2017
@dtschmitz dtschmitz changed the title backintime root crontab doesn't run backintime root crontab doesn't run (missinng line-feed 0x0A on last line bug Jun 19, 2017
@dtschmitz dtschmitz changed the title backintime root crontab doesn't run (missinng line-feed 0x0A on last line bug backintime root crontab doesn't run (missinng line-feed 0x0A on last line bug) Jun 19, 2017
@Germar
Copy link
Member

Germar commented Jun 19, 2017

Oh, good catch. Thanks for debugging!

@Germar Germar added bug Scheduling cron, anacron etc. labels Jun 19, 2017
@Germar Germar added this to the 1.1.22 milestone Jun 19, 2017
@Germar Germar closed this as completed in 01a01d5 Jun 20, 2017
Germar added a commit that referenced this issue Jun 20, 2017
buhtz added a commit that referenced this issue Aug 6, 2024
Ensure crontab file ends always with a newline. Additionally fixing behavior of accidentally adding empty lines to crontab.

Some cron implementations (e.g. cronie) would give an error otherwise.
Was previously fixed in #781 and reintroduced while with 6d77e31.

Fix #781
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scheduling cron, anacron etc.
Projects
None yet
Development

No branches or pull requests

2 participants