date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,356,718,345,000 |
I have a little VPS I run apache and a Minecraft server on. I don't ever turn it off, but should I restart it for some reason, IPTables blocks most of my ports, including port 80. I've tried so many different suggestions on fixing this, but with no luck. Also, since the provider is OVH, the support is... lacking.
So, ... |
It's because cron forcibly sets PATH to /usr/bin:/bin. You need to invoke iptables as /sbin/iptables or add PATH=/usr/sbin:/sbin:/usr/bin:/bin in your script or crontab. See crontab(5) for details.
| Not all shell scripts working with crontab |
1,356,718,345,000 |
My ubuntu VM does not run cron jobs with a TTY (not even when I log in and run the command from the user's env).
Because of this, cron can't run tmux or screen, preventing programs (specifically rtorrent in this case) to be run in the background in a simple and attachable way.
What is the best approach to running a pr... |
If you use the -d option with tmux new, it won't attach to or require a tty. From man tmux:
new-session [-AdDEP] [-c start-directory] [-F format] [-n window-name]
[-s session-name] [-t group-name] [-x width] [-y height]
[shell-command]
(alias: new)
Create a new session with name ... | What is the best way to attach to a cron program without TTY |
1,356,718,345,000 |
I have multiple cron job entries configured under a single account:
0 0 * * * /foo/foo.sh
0 2 * * * /foo/foo2.sh
0 4 * * * /foo/foo3.sh
Right now, if any of these encounter an error, an email is sent to the user account. Can I configure cron to send a notification to a different email address depending on which entr... |
It it perfectly Ok to use MAILTO= per-entry, i.e.:
MAILTO="address1"
0 0 * * * /foo/foo.sh
MAILTO="address2"
0 2 * * * /foo/foo2.sh
MAILTO="address3"
0 4 * * * /foo/foo3.sh
MAILTO="address4"
0 6 * * * /foo/foo4.sh
0 8 * * * /foo/foo5.sh
0 10 * * * /foo/foo6.sh
And so on.
Cheers,
| Can I configure error notifications on a specific cronjob entry to go to a different email address? |
1,356,718,345,000 |
On my raspberry I really don't need crons and pam logging and I want to have less i/o to make the SD card life a little longer..
I have already removed cron with the second line cron.none,
I'm currently testing the authpriv.none
auth,authpriv.* /var/log/auth.log
*.*;auth,authpriv.none,cron.none ... |
This is not the answer you are looking for, because I am going to try and dissuade you from this (which is actually the only rational answer).
On my raspberry I really don't need crons and pam logging and I want to have less i/o to make the SD card life a little longer..
If you think cron is truly doing excessive lo... | Pimp rsyslogd to have less i/o (cron, pam,...) and less logging |
1,356,718,345,000 |
When I do crontab -e, are the changes applied immediately when I save the file, or do I have to exit vim for it to be applied?
|
It waits until you exit the editor. From the manpage:
The -e option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automatically.
You can also tell by just watching stdout; it wait... | Are changes in crontab applied when the file is saved, or when the editor is closed? |
1,356,718,345,000 |
i am trying to use following commands in a shell script.. any suggestions to do it a correct way?
[root@testserver ~]# crontab -u oracle -e >> 0 0 * * * /usr/local/scrips/setup.sh
crontab: usage error: no arguments permitted after this option
Usage:
crontab [options] file
crontab [options]
crontab -n [hostname]
Op... |
The -e switch will make crontab interactive, which isn't the wished behaviour.
I suggest you use the crontab -u user file syntax. Below is an example:
root@c:~# crontab -l -u user
no crontab for user
root@c:~# echo "10 10 * * * /bin/true" >> to_install
root@c:~# crontab -u user to_install
root@c:~# crontab -l -u user
... | As root how can i create an entry in the crontab of other users |
1,356,718,345,000 |
I am trying to set up a cron job, by creating a file /etc/cron.d/myjob:
55 * * * * t echo hello > /tmp/cron.log && cd /tmp/test/ && pwd > /tmp/cron.log
I tried to verify if the job is scheduled successfully, by using the redirections. I created the file at 21:50, and when 5 minutes later i.e. it is 21:55, there is ... |
Q1
Why does the original rw-rw-r-- permission of my job file not work
From man cron:
/etc/crontab and the files in /etc/cron.d must be owned by root, and must not be group- or other-writable.
So, the files inside /etc/cron.d should be:
chown root:root /etc/cron.d/*
chmod go-wx /etc/cron.d/*
chmod -x /etc/cron.d/*
... | Why is my cron job not scheduled? |
1,356,718,345,000 |
Cronjob is based on the system time or its own time elapse? If it is system time, when I change the system time manually, will cronjob follow the new set up time accordingly?
|
cron uses the system clock, which it checks every minute. For changes to the system clock, the following extract from the man page might be useful:
Special considerations exist when the clock is changed by less
than 3 hours, for example at the beginning and end of daylight
savings time. If the time has ... | Cronjob based on system time or its own time elapse |
1,356,718,345,000 |
crontab -l | { cat; echo "0 0 * * * /path/to/cron/job"; } | crontab -
I took this line from the net, to add a new cron job. It works well and good. I got the doubts,
1) Why do we need the curly brackets (or can we use single quotes) here,
{ cat; echo "0 0 * * * /path/to/cron/job"; }
2) And why do we need the cat; co... |
1) Why do we need the curly brackets
Because you need to pipe both the output of cat and the output of echo to crontab -. Without the curly braces you can't assemble the output of the two commands in a single pipe.
(or can we use single quotes) here
Nope. ... | 'cat; echo "0 0 * * * /path/to/cron/job"' | ... mea... | Adding a crontab - syntax |
1,356,718,345,000 |
I have a bash script I wrote to backup a Moodle installation. It works fine, I've tested the backups, but there's a problem with it; when I do the backups, since I have to use sudo to type the password every time, I have to physically type in the password instead of just running a cron job to do it automatically.
N... |
I would do 1 of the following things.
Method #1 - system crons
Add the backup script to the system's crons rather then to a actual user's crontab entry. Most systems maintain a directory structure under /etc like this:
$ ls -1d /etc/cron.*
/etc/cron.d
/etc/cron.daily
/etc/cron.deny
/etc/cron.hourly
/etc/cron.monthly
... | Automating backups run from a bash script in Linux the right way |
1,356,718,345,000 |
I would like to have a service watchdog script echo the status to the screen if called like ./watchdog.sh but if it is run by cron, there is no need to echo output. What is the proper method? Where does stdout go when a script is run under root's crontab?
|
For the many cron jobs that I run, I purposely make them so if run on command line appropriate outout is generated but the same script if placed in crontab I always capture both the stdout and stderr to a log file:
00 12 * * 1-5 /home/aws/bin/myscript.sh >> /home/aswartz/rje/cron.log 2>&1
| Bash if script is called from terminal echo stdout to terminal, if from cron do not echo output |
1,356,718,345,000 |
I want to automate a task which can only be done on a website (with prior login) on my debian server.
There is no public API available, so I can't use one.
Is there a way to do so? I thought about a text-based browser or something similar.
|
You can run Selenium on a headless installation on your server, e.g. by programming the actions in python using pyvirtualdisplay.
pyvirtualdisplay allows you to use a xvfb, xepher or xvnc screen so you can do screenshot (or take a remote peek to see what is going on).
On Ubuntu 12.04 install:
sudo apt-get install pyt... | Automating tasks on a website on a headless server |
1,356,718,345,000 |
Ok I have requested a code here but initial I didn't ask to make it busybox compatible. My bad. I'm new to Linux and coding.
The code needs to do the following:
Delete 50GB of oldest data (dir with files) from a directory when the HD reaches a capacity of
95%.
The code they gave me is, that is not working with b... |
Since the busybox implementation of find does not offer custom output formatting, you need to outsource the formatting task to a separate program :) Luckily, even busybox includes the handy stat command. It's output format fields differ from the ones that GNU find uses, so the symbols you need to use are different. Th... | Remove 50GB oldest files in busybox when used capacity reaches 95% |
1,356,718,345,000 |
I want to allow non-root users to create periodic tasks but I don't want to indirectly give them root access by giving them access to crontab. Is there any alternative for them to create cron tasks that have no root access?
I could create a script myself in crontab that checks all the user home folders and runs cronta... |
By default, every user can have a crontab created. All the user needs is to be able to login to the system via ssh. After the user is logged in, all they have to do is
crontab -e
And this will open a crontab file for them to populate. After the user is done with the crontab, the file is saved in /var/spool/cron/* fo... | Crontab for non-root users with non-root execution permissions |
1,580,978,760,000 |
Just to be clear I want to comment crontab entries, not a basic file. Usually, I do it like
crontab -e
30 * * * * /u01/app/abccompny/scripts/GenerateAWRReport.pl
01,31 * * * * /u01/app/abccompny/scripts/table_growth_monitor.sh
30 0,4,8,12 /u01/shivam/script/getMongoData.sh
and I add "#" in front of each line and j... |
Export your current crontab into a file, delete the crontab, then use the previously created file.
$ crontab -l > cron_content
$ crontab -r
$ <this is where you do your stuff>
$ crontab cron_content
| How to comment all the crontab entries and then uncomment same using a script |
1,580,978,760,000 |
I notice that on Debian related systems, system level crontab scripts in /etc/cron.hourly, /etc/cron.daily... are being gradually decommissioned in favour of systemd timers. Eg:
$ cat logrotate
#!/bin/sh
# skip in favour of systemd timer
if [ -d /run/systemd/system ]; then
exit 0
fi
...
I presume that one goal... |
Users can set up systemd timers, basically by creating a service and timer in ~/.config/systemd/user and enabling the timer.
There are two main features which are lost by switching from user-defined cron jobs to systemd timers (whether that’s good or bad depends on the situation):
systemd services don’t email their r... | Is there a systemd alternative to user specified crontabs? |
1,580,978,760,000 |
I want to run a script without using cron at specific time. But it is not working.
#!/bin/sh
DATE=`date | cut -d' ' -f4`
#Date is getting printed, if I run it manually, without any error. But file is not created at scheduled time.
echo $DATE
if [[ $DATE == "07:06:55" ]]
then
echo "this is a test program" >> xyz.l... |
You can use at:
at -f "$script" 'now + 24 hours' &>/dev/null
The at command explained with an example
I found this also:
watch -n <the time> <your command or program or executable>
The watch command on the web
| What should I do to run a script on specific time without cron? |
1,580,978,760,000 |
I have added a job (register-dns.cron) to /etc/cron.daily/, but it is not running. The result of some testing is shown below.
#↳ ls -l /etc/cron.daily/
total 28
-rwxr-xr-x 18 root root 1474 Sep 13 2017 apt-compat
-rwxr-xr-x 13 root root 355 Oct 25 2016 bsdmainutils
-rwxr-xr-x 18 root root 1597 Feb 22 2017 dpkg
-rw... |
I found the problem. It seems that by removing the .cron from the end of the filename, it will start to work. (dots are not allowed in filename, see below ).
From man run-parts
If neither the --lsbsysinit option nor the --regex option is given then the names must consist entirely of ASCII upper- and lower-case le... | cron job not running from cron.daily |
1,580,978,760,000 |
I want a cronjob to run every one hour randomly. (i.e if the first job runs at 58 minutes,the second job should run at 47 minutes and the third one at 52 minutes and so on) But this should run randomly for everyone hour.
|
You can do this by defining a job which runs every hour on the hour, and sleeps for a random amount of time before running the command you're actually interested in. In your crontab:
SHELL=/bin/bash
0 * * * * sleep $((RANDOM*3600/32768)) && command
(You need to specify the shell, to ensure that $RANDOM is available.... | Running a cron job randomly for every one hour |
1,580,978,760,000 |
I have recently lost my cronjobs.
now when i do
crontab -e
i am presented with an empty file. i would like to get the default file back with the nifty comments and explanaitions at the top!
|
crontab -r should remove the current user's crontab. The next time you run crontab -e you should get the default crontab.
| How to restore default crontab file |
1,580,978,760,000 |
I need to run shell script contains Xdotool codes in /home/z/Desktop/tempo/run.sh. I've tried many ways of DISPLAY=:0 but always not works.
I've tried each of below codes, and not works:
* * * * * export DISPLAY=:0 cd /home/z/Desktop/tempo; ./run.sh
* * * * * export DISPLAY=:0; cd /home/z/Desktop/tempo; ./run.sh
* * *... |
* * * * * DISPLAY=:0 xdotool mousemove 20 20
At least should work as long as it's in the crontab of the same user as the one having the X session on the corresponding display.
If another user is to do the mousemove, you need to grant him access to your display. This can be done by giving him the MIT Magick Cookie fo... | Xdotool using "DISPLAY=:0" not works in Crontab |
1,580,978,760,000 |
This setting, for every six hours, works fine
0 */6 * * *
But this runs every six hours at 0:00, 6:00, 12:00 and 18:00
Now I want to run every six hours, but starting at 2:00. I read on this simulator that should be
0 2/6 * * *
But crontab is returning an error of "bad hour"
|
You need to provide a range
0 2-23/6 * * * ...
This will run the job daily at 2am, 8am, 2pm, 8pm (i.e. every six hours starting from 02:00). I've never been totally sure whether this is user's local time or system local time, though; I've tended to assume system local time.
| Crontab does not accept 2/6 on hour [duplicate] |
1,580,978,760,000 |
I'm fairly new to cron and I'm trying to figure out a way to run a job every day of the week, except for the first day of each month and the first day of each week.
This may sound a little odd, but the context is that this is for a backup task. I want to backup every day, but also keep some backups around a little lon... |
I would schedule the job with a day-of-the-week restriction then prefix the actual job with a date test for "day of the month". Use your own values for the hour & minute fields. The "day-of-the-month" field is *, meaning run on any & all days of the month. The "month" field is also open. The "day of the week" field is... | Cron: Run every day except first day of the month and first day of each week |
1,580,978,760,000 |
We have two servers, one of which runs Ubuntu and the other Amazon Linux 2. Both run a series of cron jobs for different clients.
The Ubuntu server sends an email (to a group email address) with the output of every cron job. There is no output redirection: just a command to execute, for each entry:
0 2 * * * /apps/ou... |
There's nothing that you can do if you stick with sSMTP. As you surmised, this is not configurable. The 5 minute timeout is hardwired into the code of the program. If your job takes more than 5 minutes, then you will simply need a different mail submission system.
| Cron email not sent by sSMTP if job takes > 5 minutes |
1,580,978,760,000 |
I have to create a cron job. I know the rules of cron but when I am using cron generator online, I can see that the resultant expressions have ? in the result. For example, if I am creating an cron expression for job to be called everyday at 4 am, the resultant expression is 0 0 4 ? * * *
What is the relevance of this... |
The ? wildcard is only used in the day of month and day of week fields:
It means ? ("no specific value") - useful when you need to specify something in one of the two fields in which the character is allowed, but not the other. For example, if I want my trigger to fire on a particular day of the month (say, the 10th),... | What does ? means in cron expression? |
1,580,978,760,000 |
Following is my crontab entry
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * /FinalSync.sh $(date --date="5 days ago" +%d_%m_%Y) || echo $? >> log
Got no error in log file also
Shell Script
#! /bin/sh
source=/Source/$1
destination=/Destination
folderParam=$(basename $sour... |
cron converts % to newline for any crontab entry. You need to escape the %s with \:
* * * * * /FinalSync.sh "$(date --date="5 days ago" +\%d_\%m_\%Y)"
| Shell script not running in crontab [duplicate] |
1,580,978,760,000 |
Is there some way to call a script of my own instead of just sending an email when any cron job fails?
|
You cannot do that with Vixie cron, which is standard on most systems nowadays, but there is a very workable alternative.
What you do is setup a special user towards which all emails from cron are redirected by setting MAILTO, in the crontab file, to that user. And for that user you make some .procmailrc entry or ent... | Run a command when any cron job fails instead of just sending an email |
1,580,978,760,000 |
I use this cron job to do a backup of /home/blah/ each day at 01:00 a.m. :
0 1 * * * tar -zcf /home/blah/backup.tgz /home/blah/
In fact I would prefer that an email is sent to me with the .tgz file as attachment. (yes, the filesize will always be < 5 MB because my folder is very small)
Can I do something like :
0 1 *... |
This following command worked for me when I tested in my machine.
echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- [email protected]
So probably the approach to follow will be something like,
tar -zcf /home/blah/backup.tgz /home/blah/
echo "Please find attached the backu... | Send backup by email with crontab |
1,580,978,760,000 |
I have setup Cron Jobs to run inside a Chroot Environment, depending on the User/Group;
I have noticed that these cron jobs, running inside the chroot environment, fail to send any mail.
Log files report that it cannot find a program to send mail.
Where does the Cron process look for the default mail binary? Can you s... |
Where does the Cron process look for the default mail binary?
Unless otherwise specified I'm fairly sure it just uses the mail program it finds in the path (/bin:/usr/bin). You can though specify the -m command line argument for some versions of cron
-m This option allows you to specify a shell command string ... | where does Cron look for the default mail binary? |
1,580,978,760,000 |
I'm trying to put up a temporary band-aid while I work out a solution for a app's memory leak. What I wrote was a small bash script that I put in the root on the server. This is what the script is suppose to do:
Get the location it's run in
Check to to see if the script is the crontab
If not in the crontab add to th... |
To create a crontab entry via a Bash script you'll need to change this line:
*/5 * * * * $path/$cronfile
To something like this:
# Write out current crontab
crontab -l > mycron
# Echo new cron into cron file
echo "*/5 * * * * $path/$cronfile" >> mycron
# Install new cron file
crontab mycron
rm mycron
You could als... | Script to test for memory usage [closed] |
1,580,978,760,000 |
I'm setting up some shell scripting to be executed every five minutes, then every minute on our client's system, to poll a log and pull some timing information to be stored and accessed by another application through an external file. The current implementation we have in place works fine as it writes a single line to... |
There is no guarantee that cron will run tasks in the order in which they appear in the cronfile. In fact, it may well run two tasks simultaneously. So it's definitely not a good idea to have the tasks depend on each other. For example, in your cronfile, one task creates a file and another one (or three) appends to it... | Cron job for every minute executing out of order? |
1,580,978,760,000 |
A python script to shutdown system works fine from the terminal but doesn't work when included in crontab. The script is called by cron but ends with an error 'shutdown command not found'or 'init 0 command not found'. I am using fedora 17 and the script is executed from root's crontab.
#!/usr/bin/python
import os
os.s... |
I guess the first line of your snippet is supposed to be something like:
#!/usr/local/bin/python
or, if you also make sure you set an appropriate value for PATH in your crontab:
#!/bin/env python
What does your crontab entry look like? Don't forget that cron sets a very limited environment, so you will need to provi... | Python script to shutdown system doesn't work in cron |
1,580,978,760,000 |
I need to develop a script to test if "now" (e.g. the output of date) is in a given range. For now, this range is expected to be a list of days of month (e.g. 10,11,12,13,21,22,23). And I could code that myself.
However, I would prefer to use existing tools instead of coding myself. And I expect the range requiredment... |
One possible way is to use Epoch time which is seconds from 01.01.1970 00:00.
Firs generate now date and time:
CDATE=$(date +%s)
then generate two other dates:
F1DATE=$(date -d "11:02 Feb 14 1999" +%s)
F2DATE=$(date -d "12:20 Feb 14 2024" +%s)
and then compare if CDATE is between F1DATE and F2DATE:
if [ "$CDATE -gt ... | Is there a tool to test if a date-time is in a given range? |
1,580,978,760,000 |
I want to schedule my crontab to execute a command EVERY 5 MINUTES between 00:05 and 23:55. I'm kinda new to cron, and I'm struggling to find the right way to do this... For now, I only found out how to do it between hours, not hours and minutes. Like, I know I can do it like this if I wanted to execute the command ev... |
You seem to want to execute a job every five minutes, every hour of the day, except for at exactly midnight.
You would schedule two jobs:
5-55/5 0-23 * * *
0 1-23 * * *
The first job would trigger every five minutes from hh:05 through to hh:55 every hour from 00 through to 23. This job skips every full h... | How to do a cronjob every 5 minutes between 00:05 and 23:55 |
1,580,978,760,000 |
I'm honestly not sure if this is an issue with WSL or I'm just doing something wrong for Ubuntu in general, but I cannot get the cron service to run at start on my WSL system.
It starts just fine with:
sudo service cron start
But it doesn't start at boot even after:
sudo update-rc.d cron defaults
sudo update-rc.d c... |
Old question that I just found when searching for a potential "duplicate" for another question that was just asked. Putting the answer here since this one is the first search result for "wsl start services".
There's a current answer and a future answer (based on Windows 10/11 Preview versions of WSL currently availab... | WSL Run Service at Start |
1,580,978,760,000 |
Today (in 2020, with init systemd), there seem to be many ways to schedule tasks (something I assume previously made by the crond daemon).
My trouble is to understand why there are three packages somewhat named similarly cronie..... available on my RHEL7 setup. This question seeks to get at the bottom about what makes... |
cronie is the package that contains the actual cron daemon. It is a fork of vixie-cron.
cronie-anacron provides the anacron tool that allows specifying things to run daily/weekly/monthly/etc. without necessarily specifying the exact time, so that systems that are shut down irregularly can have periodic maintenance jo... | What is the different use case of cronie, cronie-noanacron, cronie-anacron? |
1,580,978,760,000 |
I would like to make crontab run this script as a regular user:
#!/usr/bin/env bash
PIDFILE=wp-content/uploads/sphinx/var/log/searchd.pid
if ! test -f ${PIDFILE} || ! kill -s 0 `cat ${PIDFILE}`; then
`which searchd` --config /home/user/www/wordpress-page/wp-content/uploads/sphinx/sphinx.conf
fi
It simply rerun... |
It's probably because of the $PATH. Do this in your shell outside of crontab:
command -v searchd | xargs dirname
This command will return a directory where searchd is on your system or an error if you don't have searchd in your $PATH even in an interactive shell. Now do this at the top of your script you execute in ... | How to use which command in Crontab? |
1,580,978,760,000 |
I'm trying to set up a script for my school's computer that switches them off automatically at the end of the day (since most teachers forgot them on).
I thought to send a zenify warning box to inform the user that the PC is going to switch off and, if the user do not confirm in 1 minute, the PC shuts down.
I know the... |
You'll need to check the exit status and make a decision based on that. The manual for GNU timeout says that
If the command times out, and --preserve-status is not set, then exit with status 124.
So, in a shell script, you'd do something like this:
timeout 60 zenity ...
if [ $? = 124 ] ; then
echo it timed out... | If command reach timeout execute other command |
1,580,978,760,000 |
I am just starting to learn cron jobs. Basically I am going to use webmin to manage my cron jobs, I am also reading some basic information about cron jobs.
So far I've learned that /etc/crontab stores the cronjobs and /var/spool/cron/crontabs has cron jobs for different users, and that when I do crontab -e I can see a... |
There are several places where cron-jobs are stored.
The main place, is /etc/crontab (and on some systems, this is the only one). This file is edited only by root, and often allows to specify which user the job should run as.
On some systems, there is also a directory - /etc/cron.d - which complement /etc/crontab. ... | Why am I seeing much more cron jobs in webmin than in `crontab -e`? |
1,580,978,760,000 |
As a user, I want to edit my crontab.
crontab -e
gvim is launched. It prints
"/tmp/crontab.IUVYhK/crontab" [New DIRECTORY]
I can write but as soon as I try to write the temporary file, I get this error message:
"crontab.IUVYhK/crontab" E212: Can't open file for writing
However, I have no issue when using vi as edi... |
You must use a synchronous editor for crontab -e, i.e. one where the command doesn't return until the editing is complete. For example,
export EDITOR="gvim --nofork"
crontab -e
An alternative is this,
crontab -l > ~/.crontab
gvim ~/.crontab
# wait until editing is finished
crontab ~/.crontab
| `crontab -e: E212: Can't open file for writing` when using gvim (works with vi) |
1,580,978,760,000 |
I'm running LXDE on Fedora 21. My script's purpose is to extend the display across two monitors:
#!/bin/sh
xrandr --output VIRTUAL1 --off --output LVDS1 --mode 1440x900 --pos 1280x124 --rotate normal --output TV1 --off --output VGA1 --mode 1280x1024 --pos 0x0 --rotate normal
This runs without issue from a terminal win... |
xrandr needs the $DISPLAY variable set to tell it which X session it's manipulating, and that isn't being set in the cron environment.
xrandr could be working on your default local X session, or a second one that you started by running startx from a TTY, or a session to a remote display being forwarded over SSH, or a ... | XRandR script runs correctly from command line, fails as cron job |
1,580,978,760,000 |
let us suppose I have a cron job like this:
*/15 * * * * /path/to/thedaemon
The daemon (it being a python daemon via from daemon import runner) will not allow multiple instances of itself, which in itself is quite nice. It one tries to initiate it while the daemon is already running, this is the result:
lockfile.Lock... |
You can wrap your python daemon in a shell script.
When you first initiate, check if the process is already running:
pid=$(cat pid.file)
ps -ef | grep $pid | grep <command to start daemon>
if [[ $? -eq 0 ]]; then
echo "daemon already running" & exit 1
else
<command to start daemon> & \
echo $! > p... | Cron Job to Keep Daemon Running? |
1,580,978,760,000 |
When I use the command crontab -e on my Debian server as a non root user (in this case as postgres), I can't edit it because of "/tmp/crontab.SJlY0Y/crontab" [Permission Denied]
crontab -l on the other hand works fine. How can I fix this problem?
Here are the current permissions:
$ ls -l /tmp/crontab.SJlY0Y/crontab
-r... |
$ ls -l /usr/bin/crontab
-rwsr-xr-x 1 root root 36K Jul 3 2012 /usr/bin/crontab
The ownership and permission should actually be
-rwxr-sr-x 1 root crontab 35880 Jul 3 2012 /usr/bin/crontab
Since Debian sarge, crontab is setgid crontab, not setuid root, as requested in bug #18333.
This is the cause of your probl... | Cannot edit crontab as non root user |
1,580,978,760,000 |
I tried using crontab -l from my terminal as root, it showed no crontab for root. So I tried crontab -e, it returns the following
no crontab for root - using an empty one
888
and then the cursor starts blinking. I am not able to quit or save the file.
|
When you run the command crontab -e it typically defaults to the vi or vim editors. If you type the command Shift+Z+Z you can save any changes in this editor and exit.
To add entries to your crontab using this method you'll need to learn how to use this editor more extensively, which is beyond the scope of this questi... | Crontab suspicious activity |
1,580,978,760,000 |
I'm managing multiple machines running Debian, Raspian, and Mint. On some of the machines I want to have updating and upgrading automatically. I've drafted a script that I want to do this and log if the update are successful or not.
#!/bin/bash
captains_log=/home/jason/mission_control/captains.log
apt-get update;
i... |
The recommended way to do this is using the unattended-upgrades command. Setting it up is simple:
apt-get install unattended-upgrades
dpkg-reconfigure unattended-upgrades
This is all you need to get the results of what you intend in your cron script. There is no need to reinvent the wheel.
As far as your script and i... | Automatic Update Script using Cron, Exit Codes, and Logging |
1,580,978,760,000 |
So I have a crontab that have this line:
30 16 * * * (time sysbench --test=cpu --cpu-max-prime=20000 run) 2>> ~/cpu.out
I use this because time output goes by default to stderr and I want to redirect it to a file
When I run the command in the terminal it does write the output I need:
real X.XXXs
user X.XXXs
sys X.XX... |
When you're running it in the shell, you're actually using the bash built-in function, which looks like this:
anthony@Zia:~$ time perl -e 'sleep 1'
real 0m1.003s
user 0m0.000s
sys 0m0.004s
Cron isn't using the bash built-in; it's using /usr/bin/time:
anthony@Zia:~$ /usr/bin/time perl -e 'sleep 1'
0.00user ... | Running time command with cron |
1,580,978,760,000 |
Would someone suggest any handy command line (NOT web) tool or script which adds, enables and disables Cron jobs? I am looking, for example, for the following (or similar) behavior:
sh manageCron.sh -idJob 'job1' -addJob '* * * * * <do some job>'
sh manageCron.sh -dissableJob 'job1'
crontab -e command is good for ma... |
crontab -u USER -l will list the crontab to STDOUT.
crontab -u USER FILE will load FILE as crontab for USER.
Now the only thing that is missing is a way to identify your "jobs".
"AddJob" will add a line to the output of the current crontab and read it as new crontab.
"DisableJob" will just put a comment in front of yo... | Is there any handy command line tool to manage Cron jobs? |
1,580,978,760,000 |
In short: On a Slurm cluster, I need some computers to be available and responsive to their respective owners during work hours.
Problem: I manage a small (but growing) heterogeneous cluster with around 10 nodes, where some of the nodes are not dedicated. These are desktop computers used by colleagues on the same netw... |
After a couple of days I managed to answer my own question. In hindsight it was quite simple.
Responsiveness:
The slurmd daemon can be started with command line arguments, list them with slurmd -h. In particular , slurmd -n 19 sets the highest nice-value (and thus lowest priority) for the daemon and all its subprocess... | Slurm on desktop computers, how to prioritize the owner |
1,580,978,760,000 |
I have just installed Cygwin on my Win Server 2008. I have a bash backup script (to backup some user files to an external harddrive) that I want to run on the machine, under crontab, every night. I have just installed the base package, cron and cygrunsrv. Now I need to make crontab run. In Cygwin there is /bin/crontab... |
Both cron and crontab are commands.
cron is the daemon, running in the background and executing the commands defined in a crontab file
Cron searches /var/spool/cron for crontab files ... Cron examines all stored crontabs and checks each job to see if it needs to be run in the current minute. When executing commands,... | /bin/crontab and /usr/sbin/cron in cygwin - what is the difference? |
1,580,978,760,000 |
How can I list all cron jobs which are scheduled to run? I need to check if my cron jobs are working.
I guess they don't even run, because our Magento does not send out any order confirmation emails anymore.
|
From the comment of @Marcel
You should check /var/spool/cron/* and /etc/cron.*/*. Also, /etc/crontab
| Show all scheduled cron jobs |
1,541,013,171,000 |
I heard that /etc/crontab and /etc/cron.d/* can only be edited manually without crontab command from How would you edit `/etc/crontab` and files under `/etc/cron.d/?.
Do I need to run crontab -e to create and edit a user-specific crontab file under /var/spool/cron/crontabs/?
Can I just manually create and edit a cron... |
With Vixie Cron, they're just ordinary files — as long as you get the permissions right, you can edit them as you wish. Cron will notice the modified files and reload the crontab (it checks once per minute). This is all actually documented in the cron manpage "NOTES" section, at least on Debian.
But you really should... | Can I manually create and edit `/var/spool/cron/crontabs/t` without `crontab -e`? |
1,541,013,171,000 |
Question
How to ensure keyboard backlight is on (at max) at boot time on a Dell laptop?
Rationale
I sometimes hit the combination of keys which turns off the keyboard backlight at day time not noticing it, and then when I wake up, in the middle of the night usually, I don't want to wake up my wife by turning the light... |
No matter that the maximum value should most probably be constant, I don't know why or how but at previous boot I had the maximum value of 3. Now I have 2. I'm confused and baffled at the same time.
I don't want to search for a reason, such as BIOS setting, let's just read the maximum value at boot time and set it. No... | How to ensure keyboard backlight is always on (at max) at boot time? |
1,541,013,171,000 |
The whole day, I am fixing bugs in mainly TLS area, but this question is not specifically about TLS.
Well, I have one web server with a few web sites, each with its own SSL certificate.
But to the point, I managed to install Certbot version 0.19.0 on my Debian 9.2 like this:
Adding backports to the sources:
deb http:... |
The actual command run by cron is:
test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(3600))' && certbot -q renew
It starts by testing some files
test -x /usr/bin/certbot -a \! -d /run/systemd/system
which translates in
does /usr/bin/certbot exist and is executable (-x /usr/bin/certbo... | How to validate / fix an error in Certbot renewal cron |
1,541,013,171,000 |
I terminated the gnome-pty-helper process with
$ kill -9 9753
After a while it was running again with another process number.
There wasn't a restart of a system.
Why is it located under ~/.config/gnomy-pty-helper?
$ file gnome-pty-helper
gnome-pty-helper: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux)... |
gnome-pty-helper is automatically started by the VTE library when necessary. If you want to avoid its running (why?), you should avoid using anything built with the VTE library (libvte*).
The elements you’ve added recently make this look more like a compromise of some sort: ~/.config shouldn’t contain binaries, and gn... | Prevent gnome-pty-helper from running again |
1,541,013,171,000 |
I have setup ssh keys without a passphrase (Ubuntu) and copied them to my remote server (Centos6). I can login with ssh without a password successfully under my username.
When I execute the following script in a terminal under my username (not root) it works. When I execute it through cron under my user name it fail... |
The -i option of ssh is supposed to input the file name that contains the private key, not public key. But you have presumably given the file name containing the public key, given by the name /home/<username>/.ssh/id_rsa.pub.
Assuming the private key is in /home/<username>/.ssh/id_rsa, the following should work:
rsync... | passphraseless access to rsync with ssh through cron fails |
1,541,013,171,000 |
I get entries like these in /var/log/cron, in a host named SERV2 (RHEL 6.2):
Apr 21 14:50:01 SERV1 CROND[14799]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Apr 21 15:20:01 serv2 CROND[24438]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Apr 21 15:00:01 SERV1 CROND[14838]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)
Entr... |
The syslog format typically contains a timestamp, hostname, app name, and process ID along with whatever custom message was sent. All of these values are (substantially) under the control of the process that sends the syslog message. The cronie source (if configured to use syslog) uses the openlog and syslog functions... | Separate server's hostname appearing in this server's cron logs |
1,541,013,171,000 |
I'm trying to set up a Raspberry Pi to check a repo on startup and then fire up a node script with forever.
I got the second part working, but I tried a dozen git commands with no success.
Here is my crontab that I access like so:
crontab -u pi -e
@reboot /bin/sh /home/pi/code/script.sh
Now my script has -rwxr-xr-x ... |
After getting help to debug and trying out Phlogi's solution without success, I decided to go back to the original crontab and just add code to wait for the network interface to be ready. Here is what the script looks like now:
#!/bin/sh
while ! ping -c 1 -W 1 bitbucket.org; do
echo "Waiting for bitbucket - netwo... | Crontab shell script git pull and forever start |
1,541,013,171,000 |
I have the following output as a user running crontab -l:
#Ansible: backup-external chaos
*/20 * * * * flock --nonblock /home/mu/.cache/backup-external.lock backup-external chaos
*/20 * * * * /home/mu/bin/ddc-save-brightness
Neither job is executed. If I run them manually, they seem to work just fine.
The Ansible sni... |
This was resolved in this bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1298192
Please make sure you have the latest kernel: 4.3.3-301
| User cron jobs are not being executed any more (perhaps SELinux) |
1,541,013,171,000 |
I have a RHEL server that I am running a MySQL database on. I have a Bash script that executes mysqldump that creates a backup file. The backup file created when executing the script directly in Bash is 754259 bytes in size. If the same script is run via cron, it's only 20 bytes in size.
As far as I know, cron is... |
The mysqldump command returns nothing, which is piped trough gzip and ends in an empty gzip file. See:
$ echo -n "" | gzip -9 > test.gz
$ stat -c %s test.gz
20
This results in a file with size 20 bytes. So the problem is the mysqldump command. Since it's root's crontab the script runs with root priviledges. sudo is ... | Shell script executed with cron results in different size file than executed manually |
1,541,013,171,000 |
I use a mobile data connection service. I only have unrestricted bandwidth between 9am and 4pm.
I wonder how I can "silence" applications such as the Dropbox applet outside that schedule.
I thought about replacing the Dropbox binary with this script:
#!/bin/bash
H=`date +"%H"`
if (($H >= 9 && $H < 16))
then
echo "... |
Use cron to start the daemon and to kill it. Since dropbox runs as a user, edit your cronjob as your user: crontab -e and in the editor, place:
0 9 * * * $HOME/bin/dropbox-daemon-path
59 16 * * * pkill -u "$LOGNAME" dropbox-daemon-process-name
At 9am it starts the dropbox daemon (you should provide the full path here... | Only allow process to run between hours x and y |
1,541,013,171,000 |
Given a job specification in crontab, is there any way to get the list of dates and times the job in cron will run in the next week?
For example, given a string 10 13 * * *, is there any way to get from cron or a similar builtin or utility the (ideally sorted) list of times when the job will run in the next week?
|
You can use this perl script :
#!/usr/bin/perl
# Base on http://search.cpan.org/~pkent/Schedule-Cron-Events-1.8/cron_event_predict.plx
# initial release 20091001
use warnings;
use strict;
use Schedule::Cron::Events;
use Getopt::Std;
use Time::Local;
use vars qw($opt_f $opt_h $opt_p);
getopts('p:f:h');
if ($opt_h) {... | Get chronological list of dates & times for scheduled tasks in cron |
1,541,013,171,000 |
Debian seems to have directories for cron jobs such as /etc/cron.daily and /etc/cron.hourly, but is there a way for me to automate editing, removing, and updating cron jobs from an automated script?
I'm working on a Docker container and I'd like to allow the user to specify the cron frequency of a specific task to be... |
Probably you want to use /etc/cron.d, where you can place full system crontab entries (as you'd put in /etc/crontab) in their own file. Then you can set the intervals, enable, and disable it by manipulating that file.
| Add a custom CRON job from the command line? |
1,541,013,171,000 |
I have several shell scripts (bash) which are started by cron. Every time a script is executed I get an email saying "stdin: is not a tty". Can someone please tell me how to fix this? All scripts run successfully but these mails are killing my email folder.
I use Debian Wheezy. "/root/.bashrc" is empty. Cron entries a... |
Something in your .bashrc is assuming that the shell is running on a terminal. That's perfectly fine: .bashrc is supposed to run only in interactive shells, and interactive shells are supposed to run only on terminals.
The problem is that you're systematically including .bashrc from .profile. That's wrong: you should ... | "stdin: is not a tty" mails for running scripts as cron jobs |
1,541,013,171,000 |
I want to run a nodeJS web server on a couple of machines which I don't have sudo access on. What would be a good way to do this?
The two requirements are:
running the service without being logged in (obviously)
automatically restarting if the machine is rebooted.
For 1., I've typically used nohup but is this a re... |
You could use @reboot as the crontab startup field to make relatively sure it hasn't already been started.
| Running services without sudo |
1,541,013,171,000 |
I'm running Ubuntu 12.04 and bash. I've written a pair of shell scripts that allow me to set an alarm which, after ringing, unsets itself. The first, alarmset, allows me to enter a time and modifies the alarm line in my user crontab. That line launches the second script, alarmring, which launches a radio player in a b... |
Entries in the systems crontab (/etc/crontab) or to the directories (/etc/cron.d -or- /etc/cron.hourly, etc.) run as root. It's probably the case that root doesn't have the ability to access a given user's display by default.
I'd suggest making crontab entries using the user's ability to add crontabs. This can be acc... | Strange crontab-script interaction (bash) |
1,541,013,171,000 |
I need to add a crontab entry which runs every quarter ,on second sunday ,at 02 am.
Which of the below one is correct? the OS is AIX.
00 02 8-14 */3 0 && /myscript.sh
or
00 02 8-14 */3 * [ "$(date '+\%a')" == "Sun" ] && /myscript.sh
|
The minutes, hours and month are correct.
There is an interaction between day of week and day of month. Your first version will run on every day from 8th to 14th, and on every Sunday (but not twice if e.g. the 11th is a Sunday).
From man -s 5 crontab:
Note: The day of a command's execution can be specified by two fie... | Crontab scheduling for specific option |
1,541,013,171,000 |
I have a bash script in crontab that runs @reboot:
The script itself contains a wget command to pull and download a file from the internet
When I run my script after signing in and opening the terminal it works and saves the files properly(html, png). But when I reboot my system it saves runs and saves as plain text ... |
The issue is almost certainly that your @reboot cron job has started before your network interfaces have come up. This is, in general, a well-documented shortcoming of cron. It doesn't mean the @reboot facility is useless, it just means you need to understand how it works, and how to work around it when it fails - as ... | wget saving files as emply plain text files on boot |
1,541,013,171,000 |
I have users root and user1
All of my python scripts have been
created by user1
I have created a bash file that needs to be automated. The bash file calls my python scripts
I have added my bash call to the cron file
However, my python environment for root is not the same as it is for user1 (different versions, libr... |
Have you tried using sudo su?
sudo su -l "user1" -c "/path/to/bashscript.sh"
Alternatively you could set the required environment at the top of your crontab:
SHELL=/usr/local/bin/bash
PATH=<user1 path>
LOGNAME=user1
USER=user1
HOME=/home/user1
And if necessary source your user1 config file(s) prior to executing your... | Run cron jobs in intended python environment? |
1,541,013,171,000 |
etckeeper should log all config changes on a system. But there is one important setting that is outside of /etc/:
crontab -e edits a file inside: /var/spool/cron/crontab/ so there are important config files on the server.
How do I include those files to the git repository of etckeeper?
|
It's still a bit awkward, but if /var and /etc are in the same filesystem you could create a directory under /etc with hard links to files that aren't in /etc.
To make it easy to restore, you could do something like /etc/extrafiles/var/spool/cron and then use something like cp -l to create the hard links to files.
On ... | Let etckeeper monitor /var/spool/cron too |
1,541,013,171,000 |
I am trying to familiarize myself with crontab. I know that it is supposed to send an email containing the output of jobs to the user that scheduled them however, I can see in the syslog that the address crontab is sending emails to is not a "local" one (as if I were to type mail -s "email here" username) but an exte... |
man 5 crontab
If MAILTO is defined (and non-empty), mail is sent
to the user so named. MAILTO may also be used to direct mail to multi‐
ple recipients by separating recipient users with a comma.
| Where does crontab get the email address of the user it emails / where are user email addresses set? |
1,541,013,171,000 |
I have a cron job which runs a long script producing lots of output. Some of the output is lines delimited by single carriage returns; when run from the command line, these make the successive lines overwrite each other, providing progress output without overly polluting the backscroll. However, when looking at the ou... |
It turned out that the issue lay with mailx's pager setting. It began using more for some reason, when previously it had used less (which does the escaping). Linking more to less again restored the old behavior.
| Control character handling in cron/mailx |
1,541,013,171,000 |
At my job, we have a central Backup server, running Debian Wheezy, and on-site servers at each site, also running Debian Wheezy.
A few weeks ago, the central office tech emailed me that the backup did not complete properly the night before. We have been troubleshooting ever since, but still cannot seem to solve the is... |
If something happens when you run a job in a crontab at a certain time and it doesn't happen if you make a test where you run the job in one minute, there are two likely possibilities:
There's another process on a crontab that somehow interferes with yours.
There's a human process going on at that time, such as the c... | RSync Error in script |
1,541,013,171,000 |
I have cron and sometimes at on an ubuntu 14.04.
jobs output should be mail to me, but failed.
I make a .forward in my home dir. mail explicitly send to local unix user is forwarded to my corp mail fine.
echo [email protected] > .forward
date | mail archy
I receive the mail at [email protected].
however, cron and a... |
for cron you can to add a line to your crontab:
[email protected]
maybe there is already a wrong MAILTO line in your crontab?
But it might be better to find a universal solution, such as this:
Add line(s) to /etc/aliases (one for each user for which you wish to substitute a destination email address):
root: [email pr... | cron and at send mail to wrong user |
1,541,013,171,000 |
I have quite a strange problem using cron. I distilled it thus far:
I created following simple bash script in /home/user1/cron_dir/cron.sh:
#!/bin/bash
echo "Success"
As user1 I created following crontab:
*/1 * * * * sh /home/user1/cron_dir/cron.sh
This gets installed and runs as expected (getting a "Success"-messag... |
Answering this question because it'd bad form to just edit your question to put the answer inline (really, just answer your own question, it's okay if done in good faith).
I had a similar problem - jobs started via cron appearing to work the first few times, but then failing. The symptoms all traced back to an inabili... | Cron can't access my home directory when I'm logged out |
1,541,013,171,000 |
How can I execute logRotate daily at a specific time (3h30) each day? Specific details on how to do this would be appreciated.
I'm on Debian.
|
Step #1 - create script
You can create a file such as this:
$ sudo gedit /etc/cron.d/logrotate
And add these lines to this file:
#!/bin/bash
/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
Step #... | Daily logRotate for apache at specific time |
1,541,013,171,000 |
I am trying to add a job to my crontab in FreeBSD but it is not working :
I have used this to add the job: sudo crontab -e -u vaibhav
@daily /home/vaibhav/applications/comparison/scrapy
but it is not working. Is there any way to check whether crontab is able to run this script, like --run-parts in Ubuntu?
|
While setting up a cron you have to keep in mind a lot of thins
1.The user for which you are trying to set the cron must have permissions over the script i.e. executable permission
chmod +x /path/to/scrapy
2.The other imporatnt thing is to make sure that manually the script performs the action it is intended to.
3.Mak... | How to add crontab in FreeBSD |
1,541,013,171,000 |
I'm trying to get this simple bash script to work within a cronjob.
It's used to generate static nginx webserver statistic pages using GoAccess.
I tried everything I know to resolve this issue, it just won't work as a cronjob.
It's executed perfectly in console. It's even working as cronjob when I remove the call to g... |
This should do it. Just make sure you got the right paths. BTW, GoAccess is nifty.
#!/bin/bash
PATH=$PATH:/home/
_logdir="/srv/www/logs"
_logfiles="${_logdir}/access_*.log"
for logfile in $_logfiles; do
_curfilename="${logfile##*/}"
cat "${logfile}" | goaccess -a > "/srv/www/stats/${_curfilename}.html"
done
Y... | Bash script doesn't work as cronjob |
1,541,013,171,000 |
I would like to know how accurate and certain cron timing is. Lets say I got cronjob to run at 11:00:00 and then I pass time as a parameter for this cron job. Would it be possible, in any scenario, that the time in the parameter would be different, like 11:00:01 for example. Can I be 100% sure that the execution will ... |
Just by checking through my own syslog I can see that cron jobs usuallY start 1 second past the minute (Ubuntu 20.04). (Eg: ten past five triggers at 05:10:01). On my system this is pretty stable, but I wouldn't garentee it.
Under heavy load this might be worse because even if the cronjob triggered at the right time,... | Cronjob timing accuracy - planned time as a parameter |
1,541,013,171,000 |
When tailing /var/log/cron i noticed that the cron job is failing due to PAM permissions. In my access.conf i do have the following uncommented to make sure (or what i thought was making sure) that root did have permissions to run cron jobs.
# User "root" should be allowed to get access via cron .. tty5 tty6.
+ : ro... |
I ended up rearranging my access.conf to the below. In a sense i put the cron entry as my second entry in the config file which seems to correctly set the permissions for root to accessing cron.
#
# Disallow non-root logins on tty1
#
#-:ALL EXCEPT root:tty1
#
# User "root" should be allowed to get access via cr... | (root) FAILED to authorize user with PAM (Permission denied) |
1,541,013,171,000 |
I have a command in my crontab to monitor a service (specifically, check whether the Tor version of my website can still be accessed): this monitoring command succeeds if it can access the site, and fails otherwise (and I get an email). However, because of intermittent failures of Tor, I get emails every now and then,... |
The following script can be used as the wrapper that you describe. It saves the standard output and standard error streams of the given command to a state directory ($HOME/states) and also stores the number of failed runs.
If the number of failed runs of the command exceeds 10 (or whatever number is given to the -t c... | Warn in crontab if command has failed multiple consecutive times |
1,541,013,171,000 |
In my crontab, I reference a shell script, print-size, that contains the following lines.
#!/bin/sh
tmux new-session -t check-size -d
tmux send-keys -t check-size 'echo $COLUMNS $LINES' C-m
When this script executes as a cron job, it prints 80 23, apparently because the default terminal size is 80x24. If I execute t... |
Checking the source code is the way to go: tmux only looks at the system's notion of the size in check-size, and before that, when attaching to or creating a session, it starts with 24x80. The latter is configurable with the command-line -x and -y options.
The manual page lists this in new-session:
The new session i... | How do I set tmux's window size in a session started by cron? |
1,541,013,171,000 |
Debian has a cronjob /etc/cron.d/mdadm that starts a raid check (& resync?). It costs a lot of IO and can take up to 96 hours on 3TB disks. At this time the performance of the service will go really down.
My question is: As far as I know, Linux will immediately restore the failed RAID. Is it really necessary to run th... |
No, it's not really necessary. I used to disable it on most systems.
It can, however, be useful. Linux mdadm RAID will only detect errors that occur while the RAID filesystem is being read or written to. This mdadm raid check cron job, just causes the entire raid array to be read so that read errors can be detected... | Soft raid1 schedule resync |
1,405,071,060,000 |
I recently migrated from vixie-cron to fcron, on my laptop. How does fcron knows if a particular job was run in given period of time?
As a file can change during running, what constitute a different job? If I change, for example, from running daily to weekly, will it be re-run?
|
During initialization (and at any time a user runs fcrontab -z), fcron loads and compiles the fcrontabs. Fcron then computes the time before the next job execution and sleeps for that time.
The time remaining until next execution is saved each time the system is stopped.
| How does fcron know whether the job was run? |
1,405,071,060,000 |
I wrote the following crontab task which should switch my backgound image every 10 minutes on linux mint:
*/10 * * * * /home/me/Pictures/wallpapers/switcher.sh >> /home/me/Logs/wallpaper.log 2>&1
Which calls this shell script:
#!/bin/bash
gsettings set org.cinnamon.desktop.background picture-uri $(/usr/bin/python3 /h... |
DBUS_SESSION_BUS_ADDRESS has to be set as an environment variable. Its proper value can be set via the following script, taken from this question asking How to change Gsettings via remote shell?
#!/bin/bash
# Remember to run this script using the command "source ./filename.sh"
# Search these processes for the sessio... | Crontab fails at switching backgrounds linux mint |
1,405,071,060,000 |
I have picked up a habit of including . from some blog post:
0 0 * * * . /usr/local/bin/somescript.sh
...instead of:
0 0 * * * /usr/local/bin/somescript.sh
For instance a visual cron schedule expression editor cron.guru considers using the character as an error, but my scripts appear to have ran as specified at lea... |
cron passes the entire command, including a dot if present, to a shell for execution; so . is the corresponding shell command, which “sources” the script in the current shell instead of launching a new process to run it. For an .sh file, that would probably be a new shell.
See What is the difference between sourcing (... | What effect does a dot character . have in a crontab? |
1,405,071,060,000 |
I have installed rescuetime on debian 9. It requires the command rescuetime to be run in a terminal, this just keeps running rather than running and closing (it adds an icon into the tray at the bottom left of the screen). I'm having some difficulty getting this to run on startup.
I have tried crontab and added @reb... |
Add the commandline to 'startup applications'.
This worked for me (at least on Ubuntu 18.04).
| How to automatically start Rescuetime on startup (tried crontab and rc.local) |
1,405,071,060,000 |
Goal: Have crontab running at start up logging output from arp command in a txt file.
> Chrontab:
>
> # daemon's notion of time and timezones.
> #
> # Output of the crontab jobs (including errors) is sent through
> # email to the user the crontab file belongs to (unless redirected).
> #
> # For example, you can run a... |
The problem seems to be that probably crontab does not know the PATH where the arp command lives.
I would use:
* * * * * /usr/sbin/arp -n >> results.txt
However, I would use arpwatch to monitor ARP changes. It work as a daemon, and as it registers the MAC changes in a file over time, together with the epoch time of t... | Save arp output in terminal to text file every minute using crontab |
1,405,071,060,000 |
I have this sh script:
ufw allow 27017 && iptables -F
in a file test.sh
And I want to run this with a cronjob with root each day at 07:00 like this:
0 7 * * * /root/cron/test.sh
And I have also checked if this script actually runned with grep CRON /var/log/syslog and I can see that indeed it runned:
Aug 24 07:00:01... |
Cron jobs are run in a shell environment that may well be different from what your ordinary interactive shell environment is. For example, the PATH variable may have a list of different directories in it and may lack some directories that you are used to being able to execute utilities from.
Figure out where the ufw ... | Cronjob won't run properly |
1,405,071,060,000 |
I have 2 commands that need to run every hour, so I put these in /etc/cron.hourly/hrcron file, in following format
command1; command2
It should've worked in my opinion, but does anyone have any idea what's stopping it from running?
I'm running CentOS 6.8.
|
Files placed in /etc/cron.hourly, cron.daily and cron.monthly need to be executables. If you place a text file with a single line as shown in your question into that directory, it cannot be run at all for the same reason that you could not run such a file as a shell script from the command line, either.
What you mean ... | How can I run two commands in succession from cron? |
1,405,071,060,000 |
We have a job that is set to run Monday thru Friday. Up until two weeks ago, it ran fine 5 days a week. For the last two weeks it has failed on Monday. I am unable to locate where to find the point of failure.
### Example Scripts
0 2 * * 1-5 /admin/scripts/example.exp 1>/dev/null 2>&1
We run AIX 7.1.
I've looked in ... |
The error message c queue max run limit reached means that you have reached the limit of concurrent cron jobs.
I believe that the default setting for cron on AIX is 50 concurrent jobs, so you really need to investigate why you have 50 jobs running at the same time. (Perhaps they are multiple instances of the same job ... | Cron job doesn't run once per week |
1,405,071,060,000 |
On Debian 8.1, I'm using a Bash feature to detect whether the stackoverflow.com website is reachable:
(echo >/dev/tcp/stackoverflow.com/80) &>/dev/null || echo "stackoverflow unreachable"
This is Bash-specific and will not work in sh, the default shell of cron.
If we, on purpose, try the script in sh, we get:
$ /bin... |
Upon further testing, I suspect the & is messing with your results. As you point out, &>/dev/null is bash syntax, not sh syntax. As a result, sh is creating a subshell and backgrounding it. Sure, the subshell's echo creates stderr, but my theory is that:
cron is not catching the subshell's stderr, and
the backgroundi... | Cron only occasionally sends e-mail on output and errors |
1,405,071,060,000 |
I am using Solaris 10, and I am adding many cronjobs to my server's crontab.
Currently I have 30 cronjobs in my crontab.
one cronjob takes 8 hours to complete ,one other cron job takes 5 hours to complete it and rest of them are ordinary cronjobs (max 30 mins they take)
As it is a production server, I am worried about... |
Short answer: Yes.
Longer answer:
Depends on what the cronjobs do and when they do it, i.e. computation-heavy (performance-degrading) tasks run at night (or when no one is in the office, depends on what the server is used for) don't hurt (if they're finished before office hours, of course).
If there is a limit (I'm ... | Is crontab related to server performance? |
1,405,071,060,000 |
I am having trouble figuring out how to set up my first cron job. I simply want to run this command once every week:
dpkg -l > ~/Dropbox/installed_packages
My /etc/crontab file contains the line
7 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
So I need to place my ... |
Create a file with the following content (e.g. list_packages.sh):
#!/bin/bash
dpkg -l > ~/Dropbox/installed_packages
Place this file in /etc/cron.weekly/ and it will run once a week.
| Weekly cron job to save list of installed packages |
1,405,071,060,000 |
Why does the human readable format of the memory tool free print its numbers using full stops when I print it, but when its run by crontab it uses commas?
Sample:
free -h
total used free shared buffers cached
Mem: 3.7G 2.3G 1.4G 145M 675M 869M
-... |
Your locale settings are different in your shell and in your cronjob. You can check by running locale in both settings, and you can change your cronjob's locale settings by setting the appropriate variables (LC_ALL is the hammer if you don't need to be subtle; see locale(7) for details).
| Why does the output of free -h use different digit separators when run by cron? |
1,405,071,060,000 |
Is there a way to schedule a task using crontab by root user but should not be visible using crontab command i.e, crontab -l either for root user or normal users?
|
If you want to schedule a task using cron, an alternative to crontab in many distributions is to add a file to /etc/cron.d, in the traditional system crontab format (the variant which specifies the user). Tasks defined in this way do not show up in crontab -l's output.
For example, on Debian, amavisd-new's Spamassassi... | How to setup an invisible cron job? |
1,405,071,060,000 |
crontab strangely does not execute my script, although the script is running just fine from the shell terminal. I already made sure that scripts are separated from each other by a new line space. However, I am suspicious about the contents of my script. crontab executes run.sh which would later run main.sh.
This is th... |
Use this syntax in the cronjob:
* * */3 * * root /bin/bash /opt/db_maintain/run.sh
You used source. That is a shell builtin command from bash. Therefore it can only be executed inside a bash shell or via a bash shell. The crontab just executes binaries, not shell commands. So you have to call a binary (/bin/b... | Task not run by crontab |
1,405,071,060,000 |
I have a program written in python; my program scrapes a value from some financial website every minute and pushes that value into my DB. My program takes like 1 or maximum 1.5 seconds to do this job. I have set a cron job to call my program every minute. I need to run my program in this way every day from 9AM to 4PM... |
Generally, stopping and starting the system cron daemon is a bad idea. Commenting out the line isn't always convenient so here are a couple of related alternatives
Use a semaphore
One solution to this requirement is to use a semaphore - or flag - to indicate whether or not the script is permitted to run. In this insta... | How to stop minute cron job? |
1,405,071,060,000 |
I am trying to write a cron for unix shell that will delete some files, say after 2 weeks or after 1 month from a specific directory.
/somedir1/somedir2/
if(somedir2) contains file with extension .txt or .log
then
check timestamp
if two weeks old delete it
otherwise don't delete.
|
Try the find command.
find /somedir1/somedir2 -name *.txt -name *.log -mtime 2w -delete
Change -delete to -print for a dry run.
| Cron to delete particular file(s) from a specific directory |
1,405,071,060,000 |
We want to follow the used space of /var/hadoop/hdfs partition , by way if used space is more the 50% then as results we run the script – do_action.bash , finally this command should be in crontab and should be run every 1 hour
Example of the partition hdfs
df -Ph | grep 'hdfs'
/dev/sdc 20G 1.7G ... |
You can run df /path/to/directory to get the df output of that directory. For example, on my system:
$ df -Ph /home/terdon
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1p6 669G 186G 450G 30% /home
So you don't need to grep hdfs, you can get it directly and then simply look at the second line (NR==2... | bash + monitor disk space usage and execute script if used space reached the threshold |
1,405,071,060,000 |
I use this script to restart Firefox overnight (to apply the package manager and addon updates):
#!/bin/bash
killall -s SIGTERM firefox; sleep 15
firefox -P "user" &
firefox -P "default settings" &
crontab (runs at 3 AM):
0 3 * * * /usr/local/bin/firefox.sh
When executed manually the script works as expected: closes... |
cron jobs run in a completely separate environment, isolated from your usual GUI desktop or terminal environment.
firefox expects to be run as a child process of your desktop environment or, at the very least to have a valid DISPLAY variable set.
It is sometimes possible to get cron jobs to start or interact with GUI ... | A basic Bash script (to start a GUI program) works partially in cron |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.