Reputation: 163
I am trying to execute a JAR file periodically (let's say every 10 minutes) in an Ubuntu environment. For that purpose, I am using the crontab command.
crontab -e
# m h dom mon dow command
1 * * * * /usr/bin/java -jar /home/vadmin/Desktop/executable.jar
I am using absolute paths, and the .jar has execution permissions. I don't know why it is not working. Any suggestion will be appreciated. Am I using crontab in an incorrect way?
Thanks in advance
Upvotes: 1
Views: 2988
Reputation: 163
First of all, my crontab wasn't correct. Now that I want to execute my command every 15 minutes, in the m(minutes) field, I have to specify in which minutes of every hour the command must be executed. For example:
# m h dom mon dow command
0,15,30,45 * * * * /usr/bin/java -jar /home/vadmin/Desktop/executable.jar > /home/vadmin/Desktop/log.txt 2>&1
With this command, my command will be executed at 2:00, 2:15, 2:30, 2:45, 3:00, 3:15 and so on.
Also it is importante the redirection of the output.
2>&1
With this, I am able to redirect the STDERR output, to the same file than the STDOUT.
Thanks everybody for your answers.
Upvotes: 2