cancel
Showing results for 
Search instead for 
Did you mean: 
Post a Question

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
5 Replies

Re: Help Cronjob Not Working

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
Admin
Admin

Re: Help Cronjob Not Working

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

Re: Help Cronjob Not Working

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

Re: Help Cronjob Not Working

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

Re: Help Cronjob Not Working

0 Kudos