cron not run script

Sherzod

Dabbler
Joined
Aug 18, 2021
Messages
16
There was a problem on freenas 11.3-U5 - cronjob starts the required task.

Code:
Aug 23 11:47:00 /usr/sbin/cron[88760]: (root) CMD (PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin" midclt call cronjob.run 21 true > /dev/null 2> /dev/null)
Aug 23 11:48:00 /usr/sbin/cron[90059]: (root) CMD (PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin" midclt call cronjob.run 21 true > /dev/null 2> /dev/null)


I see that the cronjob is runnig but the script is not launched
This is a string in the database. Screenshot 2
But there are no errors in the middlewared file.

Code:
[2021/08/23 11:47:00] (WARNING) middlewared.job.add():202 - There are 27261 jobs waiting or running
[2021/08/23 11:48:00] (WARNING) middlewared.job.add():202 - There are 27267 jobs waiting or running


After middleware restart everything works 2 or 3 times and then the script is not launching anymore.
When I start the task by hand, via the web interface, it works. But as I see it runs the script differently.

Code:
Aug 23 11:46:25 cron: (root) CMD (/root/test.sh > /dev/null)


I have no idea what can be done ... Can you help?
Thanks a lot in advance
 

Attachments

  • freenas_2.png
    freenas_2.png
    4.4 KB · Views: 148
Joined
Jun 2, 2019
Messages
591
1. Put the script on your data pool, otherwise they will be lost upon upgrade or re-install.
2. Add execute permissions to the file "chmod a+x {filename}"
3. Make sure you have the bash shebang as the first line of the script "#!/bin/sh" or "#!/bin/bash"
4. Try preceding the command with "/bin/bash " Type "which bash" to confirm the path
 
Last edited:

Sherzod

Dabbler
Joined
Aug 18, 2021
Messages
16
1. ok i tweaked it
2.
Code:
-rwxr-xr-x 1 root wheel 87 Aug 17 10:09 test.sh*
there is a access to execute
3. here is my script
Code:
#!/bin/bash

sleep 40
CUR_WEEKDAY=`date`
/bin/echo $CUR_WEEKDAY >> /var/log/testscript


log file access
Code:
-rw-rw-rw- 1 root wheel 174 Aug 23 11:47 /var/log/testscript


4.
Code:
root@xxx:~ # which bash
/bin/bash


did not help, does not work
 
Last edited:
Top