Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Mitchell_gayle
Explorer

Help Cronjob Not Working

Hey guys,

 

So, I want to setup a couple cronjobs to run a few bash scripts on my gateways. One being the healthcheck.sh. I then created an export script to take the two files it creates and export it to an FTP server.

 

Both of my shell scripts can be executed manually but when I try to setup cronjobs, they don't work. I created a user called jobuser to execute these.

 

[Expert@host]# crontab -u jobuser -l
0 1 1 1-12 * /home/admin/healthcheck.sh
0 2 1 1-12 * /home/admin/healthcheckexport.sh
25 3 * * * /home/admin/healthcheckexport.sh

 

Here you can see I have two schedules, one to run the healthcheck first then to run the export, then I have a third that I was just testing with live to see why or why it isnt working. 

 

After this I also created a healthjob cron in etc/cron.d and chmod 664 to give it proper permissions.

 

Referencing How to create a cron job on SecurePlatform OS that runs every minute 

 

[Expert@host]# cd /etc/cron.d/
[Expert@host]# ls -al
total 24
drwx------ 2 admin root 4096 Feb 16 16:55 .
drwxr-xr-x 47 admin root 12288 Feb 13 08:41 ..
-rw-rw-r--  1 admin root 51 Feb 16 16:55 healthjob
-rw-r--r-- 1 admin root 188 Jan 31 2008 sysstat
[Expert@host]# cat healthjob
56 16 * * * root /home/admin/healthcheckexport.sh

 

When I restart the cron service and tail /var/log/cron I get BAD FILE MODE which just means permission issue as far as I know in the unix. I even chmod to 777 for fun and no luck.

 

Feb 20 10:50:15 2018 host crond[31840]: (*system*) BAD FILE MODE (/etc/cron.d/healthjob)

 

I also made sure that both my scripts start with !#bin/bash I've also tried adding -f -x but that isn't recognized

 

Any help would be greatly appreciated. 

Please help it's urgent.

0 Kudos
8 Replies
Mitchell_gayle
Explorer

Expert@host]# cd /etc/cron.d/
[Expert@host]# ls -al
total 24
drwx------ 2 admin root 4096 Feb 16 16:55 .
drwxr-xr-x 47 admin root 12288 Feb 13 08:41 ..
-rw-rw-r-- 1 admin root 51 Feb 16 16:55 healthjob
-rw-r--r-- 1 admin root 188 Jan 31 2008 sysstat
[Expert@host]# cat site healthjob
56 16 * * * root /home/admin/healthcheckexport.sh

It seems that only this thing is causing the issue.

0 Kudos
PhoneBoy
Admin
Admin

What version?

And is this SecurePlatform or Gaia?

If Gaia, you should be using clish to configure cron jobs and not messing with OS files.

0 Kudos
Kaspars_Zibarts
Employee Employee
Employee

I would say the easiest should be by running those scripts as jobuser:

su jobuser -c /home/admin/healthcheck.sh‍‍

if you don't have right permissions on user profile or file access you should see it there

I would follow this SK instead if you are on Gaia How to create a scheduled job (cron job) in Gaia with frequency of less than a day 

0 Kudos
Maarten_Sjouw
Champion
Champion

When in Gaia you want to use the crontab your best bet is to use clish to enter them.

Also do not forget to make sure the output can go somewhere (the bold part below).

Sample:

add cron job MDS_backup command "/backup/scripts/FWBackupMDS >/dev/null 2>&1" recurrence daily time 1:00

Regards, Maarten
0 Kudos
JozkoMrkvicka
Authority
Authority

0 Kudos
Nandhakumar
Contributor

Hi,

i have scheduled cronjob to take auto backup of firewall config. The script works well and also it run on scheduled time perfectly. the issue here is, it doesnt survive reboot.

If firewall reboot, scheduled job in crontab got auto vanished. How can make it permanent and it should not auto vanish after gateway reboot or upgrade.

0 Kudos
Tobias_Moritz
Advisor

Did you read and followed sk77300?

It sounds like you did create the cronjob manually in expert mode and used the default account "admin" for that. This is unsupported and shows the symtomes you said. It is stated in that sk.

Either use clish (or Gaia portal) for creating cronjob, or follow sk77300 when you need the flexibility of manual created cron jobs with crontab -e by creating a special user for that.

0 Kudos
Nandhakumar
Contributor

Thanks. I haven't walk through that SK. I tried to schedule job using Gaia clish command and it worked well. Verified that cronjobs were still present in device after in place upgrade.

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events