TIPS cron script ...

womble1

Guru
Joined
Oct 19, 2008
Messages
632
Reaction score
6
Hi, I'd like to run a cron script I would like to set this up using a terminal session... how can I do that ?
 

synack

Guru
Joined
Dec 31, 2013
Messages
227
Reaction score
56
Depends on your version of linux, however most have /etc/cron.d/daily, weekly, hourly... folders where you can place an executable script file that will run on its folder's predefined schedule.

Others will require you to login to the session as the user you want your script to run as, and type: crontab -e
For this you will need to google the crontab format or try here

an example would be:
1 * * * * /usr/bin/who >> /var/log/who.log
would run the program 'who' every hour at the 1 minute mark and append the output to a log file.
*/5 * * * * would run every 5 minutes.

I'm assuming of course you know how to make a script, and make that script executable.
 

Trimline2

Guru
Joined
May 23, 2013
Messages
524
Reaction score
96
Bring up your Webmin and go to System --> Scheduled Cron Jobs. You can add and update cron jobs easily there.
 

womble1

Guru
Joined
Oct 19, 2008
Messages
632
Reaction score
6
Last time I did that it didn't work so I thought I'd use the command line.
 

synack

Guru
Joined
Dec 31, 2013
Messages
227
Reaction score
56
Well I'm using Pbxinaflash distro.....
Would that be centos, ubuntu, redhat, scientific, or one of the various "little" computer linuxes? lol

Anyway for a standard centos, you can run 'crontab -e'
also there are:
/etc/crontab
/etc/cron.d/*
/etc/cron.daily/*
/etc/cron.weekly/*
/etc/cron.hourly/*

and as a variation, 'crontab -u username -e' where username is the user context your script should run under. (because we shouldn't run everything under root they say.)

Any of them should work. If your script isn't running, it's likely a permissions issue. redirecting your scripts output to a log file is very helpful ( 2>&1 >>somelogfile.log)
 

Members online

No members online now.

Forum statistics

Threads
25,819
Messages
167,800
Members
19,247
Latest member
abuhyder
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top