cron log file location

Hi,
i have inserted on my cron the lines below to make some backups but isn’t working. I cant find where is the cron log file to see what is going wrong. Anybody can help?

My crontab:

@reboot sleep 10; mount -a -t cifs; //Works to mount my samba shares

00 23 * * * /usr/local/groovy-1.5.6/bin/groovy /mnt/ecmsrv/u/redes/scripts/groovy/backupGeral.groovy;

30 23 * * * /usr/local/groovy-1.5.6/bin/groovy /mnt/ecmsrv/u/redes/scripts/groovy/backupSisCDI.groovy;

this commands works fine on shell.

Ty all.

Cristiano Botelho

You write “your crontab”, but surely a mount command requires root privilege?

All my servers i use this line and works fine.

@reboot sleep 10; mount -a -t cifs; //Works to mount my samba shares

FYI my version is 10.3

I assume you put that in root’s crontab. I think such a command is inherently unreliable because you cannot guarantee that the network is up 10 seconds after the cron daemon is started. The startup of the cron daemon may be totally unrelated to the startup of the network.

Instead you should let the service smbfs do it, that’s what this init script is designed for, instead of cobbling your own. This script is sequenced after network. You should be able to turn on this service from YaST. And you need a cifs entry in fstab of course.

Cool. I edited my crontab as root. Will check for this service on Yast and yes i For now this command works to me. My problem is on red lines of cron. Do u know where is the log file?

Thanks for prompt replies!:slight_smile:

Normally the common syslog destination: /var/log/messages. But it doesn’t contain any output from the command, only when a job was started. Output from cron jobs normally gets emailed to root.

You could do this to capture the output:

00 23 * * * /usr/local/groovy-1.5.6/bin/groovy /mnt/ecmsrv/u/redes/scripts/groovy/backupGeral.groovy > /tmp/debug.out 2>&1

As for the groovy lines, a cron environment is missing some things compared with a login environment. The PATH is much reduced and if your script makes assumptions about the PATH, some commands will not be found.

I checked the /var/log/messages and could see that the commands are been executed normaly. The problem is on JAVA_HOME PATH when the command run. will create an script that sets the path for java and after run the groovy commands. thanks for your help. Later i post here the results!

You can do it inline in the crontab:

00 23 * * * JAVA_HOME=/somedir/somewhere /usr/local/groovy-1.5.6/bin/groovy /mnt/ecmsrv/u/redes/scripts/groovy/backupGeral.groovy

It’s not special to crontabs, it’s part of the shell. You can set environment variables for the duration of a command in the shell using that notation, for example:

$ JAVA_HOME=/alternatedir/somewhere some-java-program

works to change JAVA_HOME temporarily for that command.

Hi again.
It works fine now.Ty for your tips!
:wink:

I cant find my cron task in /var/log/messages and I know it was executed as I verified process list and it was running.

How do I see log when this task started?

??? How do you mean? Every line in /var/log/messages has a timestamp when the event happened so you know when the job was started.

This one doesnt…

I set event in 8:40, I have messages till 8:38 and returning back at 8:42
and process executed as I typed “ps -A” in 8:40 and it was running.

I don’t understand your sentences.

Only the start time of the job (by the computer clock of course) and the command are logged. It doesn’t log how long the command took, or when it finished.

If you need to know these things, you can put your own commands in the cron job before and after the work. E.g.

10 2 * * * /bin/date; /usr/local/bin/somecommand; /bin/date

The output of the job is mailed to the owner of the job, root if a system job. If you want to capture the output, you can use shell redirection. E.g.

10 2 * * * (/bin/date; /usr/local/bin/somecommand; /bin/date) > /root/job.log 2>&1