[SOLVED] Crontabs/cronjobs not working

JohnTanner

Active Member
Sep 25, 2019
43
3
28
35
Hello everyone,

i am currently facing a problem where I have some entries in my crontab (crontab -e) and in /etc/crontab. These lines or commands work on their own when I execute them via the web shell, but cron just does not execute them. there is no mail in /var/mail and no other indication of an error. I have also tried many variations of the commands (just execute a script to make the machine sleep via rtcwake) and pipe the result into a txt file but also to no avail.

i have the same problem in all of my LXC containers, so does anyone have an idea why that is?
any suggestions are very welcome
 
  • Like
Reactions: majorgear
Two potential points:
* try using full paths for your scripts (cronjobs usually have only /usr/local/bin:/usr/bin:/bin as their PATH)
* not getting mails is odd - but does the container have a mailserver configured (e.g. postfix)?

I hope this helps!
 
Two potential points:
* try using full paths for your scripts (cronjobs usually have only /usr/local/bin:/usr/bin:/bin as their PATH)
* not getting mails is odd - but does the container have a mailserver configured (e.g. postfix)?

I hope this helps!


thanks for the reply!

the script is located in / so my crontab is
Code:
0 23 * * 1 /sleep
. The way I understand it, the node this is located on, should then execute the script sleep in / at 11pm, where the content is

Code:
#!/bin/sh
rtcwake -m mem -l -s 28800

and I meant the mail in /var/mail. is postfix required for that as well?
 
The way I understand it, the node this is located on, should then execute the script sleep in / at 11pm, where the content is
yes - but only on monday - the 5th field is the day of week (1 denoting monday)

and I meant the mail in /var/mail. is postfix required for that as well?
yes
 
yes - but only on monday - the 5th field is the day of week (1 denoting monday)


yes

yeah I know it's for Monday only (I have one for every day of the week).
The task is not being executed and postfix is installed on the node, yet the /var/mail/ directory is empty :(

any ideas?
 
* check the journal - if a cronjob is started it should show up in the journal
* where is `rtcwake` - try using the full path there as well

I hope this helps!
 
  • Like
Reactions: JohnTanner
ok solved it:

it was just me being stupid...

in the crontab -e and/or in /etc/crontab, the fully qualified paths are required. say: /sbin/rtcwake and so on

same goes with the LXC crontabs (ubuntu 19.04 template). Thats also confusing me, on an entirely different machine, i got snapraid to work with just "snapraid sync" in the crontab -e...

Cron works now and my nodes go into standby at the right time.

thanks a lot for your help @Stoiko Ivanov !
 
  • Like
Reactions: Stoiko Ivanov

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!