Skip to content

Commit

Permalink
More scheduled task help page tidying. by: Giles
Browse files Browse the repository at this point in the history
  • Loading branch information
gpjt committed Nov 24, 2022
1 parent 2dd0e30 commit ad823e0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 45 deletions.
6 changes: 1 addition & 5 deletions articles/ScheduledTaskParameters.md
Expand Up @@ -11,8 +11,4 @@
-->



## Can I include parameters to be passed to my scheduled task?

Yes you can. You can just include the full command-line, including any arguments and parameters, in the "path to script" box.

See [setting up scheduled tasks](/pages/ScheduledTasks#passing-in-command-line-arguments)
17 changes: 10 additions & 7 deletions articles/ScheduledTasks.md
Expand Up @@ -21,11 +21,11 @@ of the page:
day. The task can run for up to two hours.
* In a paid account, you can create up to 20 tasks, and they can either run at
a particular time every day, or every hour at a particular number of minutes
past the hour. (The limit of 20 is "soft" -- if you need more, within reason,
then you can contact us to get it raised for your account.) Each task can run for
up to 12 hours.
past the hour. Each task can run for
up to 12 hours. (The limit of 20 tasks is "soft" -- if you need more, within reason,
then you can contact us to get it raised for your account.)

The details of how to set the task up are below.
The details of how to set a task up are below.


## Timing
Expand Down Expand Up @@ -93,15 +93,18 @@ can schedule it so long as Bash recognises it as executable. There are two
things you need to do to achieve that:

1. Include a ['hashbang'](https://en.wikipedia.org/wiki/Shebang_(Unix)) at the
start of the file. For example, if your script is a series of Bash commands,
the very first line would be `#!/bin/bash`
start of the file to tell Bash which interpreter to us. For example, if your script is written in Ruby,
the very first line would be `#!/usr/bin/ruby`
2. Make sure that has execute permission. You can use the Bash `chmod` command
for that -- for example:

```
chmod +x /home/myusername/myproject/myscript.sh
chmod +x /home/myusername/myproject/myscript.rb
```

(At a rather meta level, you could also schedule a Bash script that way by specifying
`/bin/bash` in the hashbang.)


## Common issues

Expand Down
31 changes: 1 addition & 30 deletions articles/VirtualEnvInScheduledTasks.md
Expand Up @@ -9,33 +9,4 @@
.. type: text
-->

## The simple case: without environment variables

If you want to run a scheduled task in a
[virtualenv](/pages/VirtualenvsExplained), and you're not using the virtualenvwrapper postactivate
script to set environment variables, you just need to specify the full path to
the virtualenv python inside your task's command-line.

So, eg, instead of:

```
/home/myusername/myproject/mytask.py
```

You would use

```
/home/myusername/.virtualenvs/myvenv/bin/python /home/myusername/myproject/mytask.py
```

If you need to make sure there's only one copy of your task running at a time,
see the [long-running tasks article](/pages/LongRunningTasks/)


## The more complicated case, with environment variables

If you *are* using the postactivate script to set environment variables, the
command is a little more complicated. Instead of `/home/myusername/myproject/mytask.py`, you
need to use a command like this:

source virtualenvwrapper.sh && workon myvirtualenv && python /home/myusername/myproject/mytask.py
See [setting up scheduled tasks](/pages/ScheduledTasks#using-a-virtualenv)
5 changes: 2 additions & 3 deletions articles/index.md
Expand Up @@ -283,9 +283,8 @@ Databases:

Scheduled tasks (similar to cron):

* [Using the "Schedule" tab](/pages/ScheduledTasks)
* [Can I pass command-line arguments and parameters to my scheduled tasks?](/pages/ScheduledTaskParameters)
* [How do I run a scheduled task inside a virtualenv](/pages/VirtualEnvInScheduledTasks)
* [Setting up scheduled tasks](/pages/ScheduledTasks)


Other Languages:

Expand Down

0 comments on commit ad823e0

Please sign in to comment.