Can't run cron job for working script

Linode Staff

My cron job isn't running as expected, even though the script I am trying to run with this cron job runs just fine. What's going on here?

2 Replies

It sounds like you're dealing with a pretty annoying issue here. It'd be my pleasure to help you out here.

Before I begin, I'd like to let you know that we have an excellent documentation page about cron located here:

Here are some possibilities that are coming to my mind regarding this:

  • You may need to run the cron job as a specific user, probably the one who can run the script successfully. This will be important in case the script references any of that user's configuration files or permissions, which may be necessary for successfully running the script.

    You may use this information from our cron docs page to set up cron jobs for any user on your system:

    Afterwards, you should remove the cron job for whatever user was originally configured to run it. This will help avoid any conflicts in how the working cron job runs this script.

    This page from our Documentation explains how user management and user permissions operate in a Linux environment, which will be important background knowledge for this point:

  • This may sound obvious, but it's important to ensure that your cron daemon is actively running and configured to do so when your Linode boots. There are lots of different cron varieties, and lots of differences between distributions for how to ensure that your services properly start upon boot.

    You should be able to use the package manager for your Linode's distributions to ensure that you have a cron package installed:

    Most modern distributions uses systemd for service management. You may read more about how to use systemd to start a service and enable it from this page in our documentation:

    Enabling a service ensures that it starts upon boot, so it is extremely important that you enable this cron service. This will ensure that your script runs at your expected times even after your Linode reboots.

  • I would review your cron syntax for any errors. You may reference this section from our cron docs for more details on cron's syntax:

    Different varieties of cron may have slightly different syntax capabilities. To consult the definitive syntax for your Linode's cron variety, you may run man 5 crontab on your Linode.

I hope that this information helps! Feel free to reply to this thread if you have any other questions about this.

OP --

The source of your issue is most likely the assumption you have made that cron(8) is a clone of the shell (whichever one of those you use). It's not… cron(8)'s capacity for "environment variables" is extremely limited (and they're not really environment variables…they're local only to cron(8) -- even though they have names like SHELL and LOGNAME) and cron(8) normally runs it's jobs as root or nouser -- bypassing account login and all the nice stuff you've set up in your .profile/.bashrc/.zshrc that your script probably depends on.

-- sw


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct