Cron doesn't work


(Joel Clendineng) #1

Bump, also cron does not work for me. I run a script

service bl_incremental start

where bl_increment is a service i want to start every day at a certain time. crontab -l shows “no crontab for root” meaning the cron is empty.

(Marc) #2

nethserver-crontabmanager uses the system wide crontab (/etc/crontab)

(Stéphane de Labrusse) #3

Try to put the whole path to the binary and also try directly the command in the shell

Verify also that your cron job is well written in /etc/crontab

(Joel Clendineng) #4

–cron for bl_incremental
40 9 * * root service bl_incremental start

also did a which systemctl and used the loaction : 40 9 * * root /usr/bin/systemctl bl_incremental start

Looks right, 9:40 as root

(Marc) #5

If it’s on Nethserver 7 the systemctl arguments are switched (systemctl start bl_incremental).
Also it’s missing the day of week definition (40 9 * * *), correct me if wrong.

(Joel Clendineng) #6

“* * * * * root /etc/rc.d/init.d/bl_incremental”

I had to link directly to the script, and I was missing day and week…thanks

(Stéphane de Labrusse) #7

ok in short it doesn’t work because you don’t write the full path to the file ???

(Stéphane de Labrusse) #8

@dnutan, I would like to validate in netgui that the job starts by a full valid path to a file…

good or bad idea ?

(Joel Clendineng) #9

I basically just wanted to make a cron for the firewall script. I have 2 scripts that I modified from the other thread, one for a complete redownload of blacklist ips, including ones I add and refresh/update of shorewall that runs every week and a second script that adds ips from a list I can add to from evebox and fail2ban, that runs every night, it does the same thing but without deleting the blrules file in etc/shorewall. It may have been my failure to include all the “* * * *” im not sure if crond requires all times filled with something. So it probably works fine, you just have to know cron syntax to use…which I didnt before I did this.

(Stéphane de Labrusse) #10

Well…it is for this that i created the simplified mode :slight_smile:

(Marc) #11

It could be a good idea, even though isn’t mandatory for commands in crontab’s PATH environment. Also may be hard to validate when multiple commands are concatenated. Not sure it worths the effort. :thinking:

I’d consider:

  • making command’s textarea single-line (not multi-line)
  • User field could be the same for both simplified/advanced settings
  • verify User field is not empty
  • verify time field is not empty when advanced settings are selected
  • simplified settings: verify required number of arguments are selected

A minor oddity, maybe not a problem: naming a new cronjob the same as an existing one, shows a validation error (ok) and fills empty fields of the new task with values from the existing task.

(Joel Clendineng) #12

Again, it was probably my fault, Ive not really used cron before and google wasn’t giving me consistent answers :smiley:

(Stéphane de Labrusse) #13

no problem, it is time to review the code

(Stéphane de Labrusse) #14

in fact the simplified mode could be made more simpler.

we can have a drop down with

@yearly (or @annually) 	Run once a year at midnight of 1 January 	0 0 1 1 *
@monthly 	Run once a month at midnight of the first day of the month 	0 0 1 * *
@weekly 	Run once a week at midnight on Sunday morning 	0 0 * * 0
@daily 	Run once a day at midnight 	0 0 * * *
@hourly 	Run once an hour at the beginning of the hour 	0 * * * *
@reboot 	Run at startup 	N/A

after the dropdown we could add the other options to set graphically the time job and of course also create what @dnutan added