So, I have attempted to get crontab to run a node.js file at a set time everyday. I have set it up by doing crontab -e. I have tested that it runs every minute by using the below:

* * * * * //path of files

This makes it run just fine on the minute. However, if I try to set it to a specific time, it won't run. For example, if I try to have it run at 12:48pm, it will not run:

48 12 * * * //path of files

I have tried to troubleshoot everything and it clearly a time issue. It is an EC2 server located in Oregon. I have adjusted my time to be for Oregon time and it still will not run.

Is there something special that needs to be changed with crontab command if you set a specific time vs. just having it execute every minute? Do you have to set a specific time 5 minutes or more ahead of time to make it run?

I'm at a loss as to why this will not run my file at a specific time, but will run every minute just fine.

  • That looks like it should work, provided the command set there is valid, and that the system is running at that time. If you can, take a peek at the system logs to see if there's anything odd (grep -re cron /var/log/ or something like that) – ilkkachu Mar 30 '18 at 21:15
  • 2
    Thanks, that solved it. When I ran the command, I found out that the time logs were for UTC time, so this would explain why the time wasn't working. – user7977797 Mar 30 '18 at 21:20
  • You could "Answer your own question" and provide the community with an official solution. Probably would be better for everybody in the long run. – harperville Mar 30 '18 at 22:42

The solution is provided by ikkachu's suggestion. Specifically, type

grep -re cron /var/log/ 

or something similar.

This will give a list with times and other information.

The times listed showed that the server was actually going off of UTC time. So, adjusting for UTC time solved the problem.

Finding the exact time the server is using, regardless of its actual location, is the solution to this type of problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.