Fury
Fury

Reputation: 4776

How to call a cronjob file in ubuntu

I have a cron file which is located in /var/www/html/mysite/cron/all.cronjobs

How can I call this file? The file contains of cron tasks

17 1 * * *  /usr/bin/php /var/www/html/mysite/cron/file1.php
23 1 * * *  /usr/bin/php /var/www/html/mysite/cron/file2.php  
...

Should I call this file inside cron crontab -e ? Or should I set another cron to be called?

Any help please.

Upvotes: 0

Views: 58

Answers (2)

John Leach
John Leach

Reputation: 11

I'm assuming that your all.crobjobs file is formatted like a crontab, so one or more jobs defined, one per line with the time/period definitions.

You can't "call" this file - it's not executable as it is. The contents of it need to be added to your user's crontab, using crontab -e as you suggest. Just copy and paste in the contents of all.cronjobs and save it.

Upvotes: 0

dsas
dsas

Reputation: 1660

Is your cron file a list of cron jobs you'd like to add (a crontab)?

If so you could put the file in /etc/cron.d/ (or symlink it there), though be aware that this means it'll run as root.

To replace a users crontab with yours you can do

crontab /var/www/html/mysite/cron/all.cronjobs

Upvotes: 1

Related Questions