date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,664,887,245,000
I want to do regular backups of my remote VPS via a cronjob. Both systems run Debian 10. I have been following this guide and tweaked it to my liking. Relevant parts of the script: /root/.local/bin/backup #!/bin/bash SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) rsync -avzAHXh -e ssh root@[someIP]:/path/to/r...
Commands executed by Cron have an extremely basic execution environment and path setting, a frequent error is to test a command or script as your normal user id. Then it fails when run by Cron. Exported Environment variables are often overlooked. It is prudent to do a final test, as root, with a completely cut down en...
Remote Server: Permission denied (publickey) when using rsync with ssh with gpg via cronjob
1,664,887,245,000
I notice that I am getting 2 different cron processes in ps: [user@host ~]$ ps aux | grep -i cron 500 746 0.0 0.0 6384 676 pts/1 S+ 13:40 0:00 grep -i cron root 905 0.0 0.0 20408 1036 ? Ss 2019 54:54 crond root 30406 0.0 0.1 39152 1672 ? S Feb14 0:00 CROND s...
CROND is a child process of crond; it gets created when a crontab entry is processed. $ ps -ef | grep -i cron UID PID PPID C STIME TTY TIME CMD root 2289 1 0 Feb12 ? 00:00:02 /usr/sbin/crond -n root 446475 2289 0 14:37 ? 00:00:00 /usr/sbin/CROND -n Process # ...
Why is my host displaying 2 cron processes?
1,664,887,245,000
System: Mac Big Sur I been working more in the terminal and I thought it would be fun to have a fortune present a different message regularly during login. I know I can just add the fortune command to my .bash_profile but I wanted to run it as a motd for every user of the system and schedule it with launchd/crontab. T...
The issue is most likely that the script does not have the correct value of the environment variable PATH. It is in any case not any form of syntax issue. You can solve this in one of three (or more) ways: Use absolute paths for each command, as you yourself suggest. The only instance when you need to do this is whe...
Bash or path problem?
1,664,887,245,000
I'm currently working on bash script, that will add jobs to root's crontab. I'm trying to achieve it with command: sudo crontab -e -u root | { cat; echo "@reboot /home/$CURRENT_USER/scripts/reboot.sh"; } | crontab - I'm testing this command in shell of Ubuntu Server 18.04 and right after typing password for sudo shel...
crontab -e invokes an editor. The output from the editor goes to the cat command, but (at best) it's waiting for you to edit the file. You probably should do something like this job="@reboot /home/$CURRENT_USER/scripts/reboot.sh" tab="$(crontab -l)" { echo "$tab" | grep -vxF -e "$job"; echo "$job"; } | crontab If the...
I cannot echo job to root's crontab with sudo - shell hangs
1,664,887,245,000
I have this report, but i can't understand why it doesn't recognize gradle command... I'm new to cron, thanks for your help! From [email protected] Sun Dec 13 04:02:01 2020 Return-Path: <[email protected]> X-Original-To: ubuntu Delivered-To: [email protected] Received: by vps-a29e040b.vps.ovh.net (Postfix, from useri...
cron is fairly easy to use, but it has some idiosyncrasies you should be aware of. Here's a brief summary: 1. cron jobs have a different ENVIRONMENT cron jobs run with an ENVIRONMENT that's different than your interactive shell. The PATH is part of the ENVIRONMENT. This may be the cause of your issue: the PATH to grad...
Can't Use Gradle With Cron Ubuntu
1,664,887,245,000
This is what my crontab looks like: * * * * * /bin/sh /home/rathindu/assignment/test.sh The test.sh file: #!/bin/sh mkdir new The script is not running. But if I just open the terminal and invoke the script without using crontab it works perfectly. When I inspect the CRON syslog CRON[6909]: (CRON) info (No MTA insta...
Just as @αғsнιη suggested in the comment, I replaced every relative path with an absolute path and it did worked perfectly. there was no need to use /bin/mkdir/ it just worked fine with simple mkdir. But the paths to the files had to be changed to their absolute paths mkdir new had to be changed to mkdir /home/usern...
Cronjob does not work on Linux Mint 20
1,664,887,245,000
I was newbbbie of crontab command, and while i was investigating this command, i suddenly type some number and made my crontab -e look like this: pi@raspberrypi:~ $ crontab -e no crontab for pi - using an empty one 889 is there any way to set crontab back to default or how to delete them? i just want use crontab t...
Your editor is set to ed. The ed editor is a very basic line editor which will output the number of bytes in the file when you open it. In this case, you crontab file contains 889 bytes (type ,p and press Enter in the editor to see the contents of the file). You most likely don't want to use ed as you editor (or you...
Crontab -e simple problem
1,664,887,245,000
I have installed Manjaro Linux with 5.7.0-3-MANJARO kernel. The problem is that every time I boot the system, I have to start my NetworkManager module manually with the command sudo systemctl start NetworkManager. I want my system to start it automatically. I tried adding it as a cron job with crontab -e, but it does ...
Do not try to use cron for this !Cron is meant to run repeating tasks. If you try to do it with cron it will constantly run this command again (it doesn't do any real damage but that doesn't make it a good idea either Correct solution: sudo systemctl enable NetworkManager(The difference between enable and start is t...
Setup a new startup job in Manjaro
1,664,887,245,000
I run a .sh bash file from a directory httpdocs/pub/ftp-admin/. On the command line from the directory everything works fine. If i make a cron task in plesk all magento 2 commands are not working and ik get this message. Magento supports PHP 7.1.3 or later. see script below. what is wrong. I run: CentOS Linux 7.8.200...
Problem is solved. Cron tasks in plesk are running under a lower PHP version then from SSH. By editing the script like this the problem was solved: /opt/plesk/php/7.2/bin/php -f $MAGEPATH/magento import:job:run 1
cron job task error while command line works oke
1,664,887,245,000
I'd like to run the following backup command as recurrent job where User is my username and /mnt/Rsync_Dell is a folder I created on OMV5 with static IP: sudo rsync -apEo /home/User/ /mnt/Rsync_Dell/Prova/ If I run this command on the terminal, it runs successfully, on the crontab file it fails. What I do is the foll...
Since you can't give sudo a password when using it from your own crontab, and since the purpose of using sudo in the first place is to gain root privileges, running your rsync command from root's crontab rather than from your own seems like a better option. You may edit the root user's crontab using sudo crontab -e W...
rsync back running via cron
1,664,887,245,000
Most logs on my Mac have a time stamp before the output message like this: Nov 14 17:55:24 - SoftRAID Driver: SoftRAID driver loaded, version 5.8.1. I am running an executable in cron and instead of using mail I want to output all info to a log file and add a timestamp to each line in front of the output. I am using >...
If you have (or can obtain, from homebrew for example) the ts timestamp utility, then you should be able to do something like /usr/local/bin/urlwatch | /path/to/ts >> /Users/john/cronjobs/urlwatch.log (/path/to/ts would typically be /usr/bin/ts on Linux systems; it may be another location on OSX). From man ts: DESCR...
How to redirect output to a log file from cron and prepend timestamp?
1,664,887,245,000
I have created downloads file inside /etc/cron.d/ directory. Following is the content of the downloads file. * * * * * root /usr/bin/python3 /path/python.py File permissions and owner: -rw-r--r-- 1 root root 79 Dec 25 22:45 downloads systemctl status crond Above command gave the following error. Unit crond.servi...
Append one blank line to the end of your downloads file. Cron jobs need new line termination characters. Also, it is better to manage cron jobs with crontab -e (if you want root priviledges, sudo crontab -e). In case you forget the new line, crontab will warn you.
cron not running in Ubuntu 18.04.3 LTS
1,664,887,245,000
I recently installed timeshift and set it to backup weekly. However, when I looked in /etc/cron.d, I only found timeshift-hourly which ran: 0 * * * * root timeshift --check --scripted which appears to check with timeshift if a backup is schedule and if so, do it. However, I would like to set a cron email for every t...
This is already built-in to Timeshift, just disabled by default. The following picture is from the Timeshift setting menu; just uncheck the Stop cron emails box and you should be good to go.
Timeshift weekly cron emails
1,570,835,992,000
I want putting timestamp traces into two different files when I call to the script from a cron task. One file is for stdout script.log and another for stderr script.err With this cron line I get timestamp over script.log file, but don't work with script.err */1 * * * * ((/home/user/script.sh) | ts "\%H:\%M:\%.S ->") 2...
One way is to redirect stdout of ts first, and then redirect stderr of the pipeline to stdout and pipe to another ts:: */1 * * * * (/home/user/script.sh | ts "\%H:\%M:\%.S ->" >> /home/user/script.log) 2>&1 | ts "\%H:\%M:\%.S ->" >> /home/user/script.err (Though this way, and stderr output from the first ts will also...
how to add timestamp to stdout and stderr from a crontab job?
1,570,835,992,000
I have a script(main.sh) which calls another script(Get_Files.sh) and gets a value in a variable like the below: File_to_Refresh="$(sh /Aug/work/Get_Files.sh /Aug/Work/Universal_File.txt)" Now I have to schedule the script main.sh for 3 different files i.e. the Universal_File.txt with 3 different values and on 3 diff...
If you have 3 cron entries, 1 for each day (as mentioned in comments), you should be able to specificy the file used for each cron entry as an argument and use $1 in the main.sh script $ cat main.sh File_to_Refresh=$(sh sub.sh $1) echo FileToRefresh: $File_to_Refresh $ cat sub.sh echo Sub \$1: $1 $ ./main.sh /Aug/Wo...
Cron entry to pass the value to script
1,570,835,992,000
I want to schedule a job for 3rd Friday of every month, 1 AM . I checked few cron entry websites for that didn't work for me. I was also checking for some awk options for this so far not successful with that. Can you guys help me with that? I tried to run this for today the cron is working fine but the script is runni...
Unfortunately, when you give both a day-of-month and a day-of-week in a crontab entry, this means either one is sufficient. (Didn't know that either, but the manpage says so.) This means we can't simply calculate that the 3rd friday is a friday that is between the 15th and 21st of the month. Fortunately, the above-lin...
CRON Job Schedule issues
1,570,835,992,000
I'm trying to run a daily cron app. What I did: crontab -e Inside file, I have: 0 0 * * * cd /home/ec2-user/myapp && docker-compose up when I check /var/log/cron, I get: Jul 29 00:00:01 localhost CROND[28549]: (ec2-user) CMD (cd /home/ec2-user/myapp && docker-compose up) But I have no logs in myapp, and I can t...
docker-compose can not be found in cron users PATH variable, and therefore can not be run. One way to fix this is to provide the complete path to the binary. 0 0 * * * cd /home/ec2-user/myapp && /usr/local/bin/docker-compose up
Cron logs show activity, but app logs show nothing
1,570,835,992,000
I'm running Ubuntu and got a simple cronjob fetching a remote JSON-file and (over)writing it to the server. */15 * * * * /usr/bin/curl -m 120 -s https://path/to/remote/json.json > /store/json/here.json However I need to make sure the external JSON actually returns data before it overwrites the JSON file located on th...
Write a short shell script and call the script from your crontab. The script may look something like #!/bin/sh PATH=/usr/bin:$PATH cd /store/json || exit 1 if curl -m 120 -s https://path/to/remote/json.json >here.json.tmp && [ -s here.json.tmp ] then mv here.json.tmp here.json else rm here.json.tmp fi ...
Cronjob fetching JSON with cURL. Check if response isn't empty before writing to file
1,570,835,992,000
I've been trying to get all cron job outputs to a file (not email). The alias is set in /etc/aliases. logthecron: "|cronlog.sh" And in crontab MAILTO=logthecron. The cronlog.sh file writes to output to some file: #!/bin/sh $@ 2>&1 | sed -e "s/\(.*\)/[`date`] \1/" >> /tmp/a I am using sendmail. Sendmail uses smrsh, ...
Instead of trying to use MAILTO (which will always be interpreted as an email address), use SHELL. Set SHELL to the path of a small executable shell script that runs the given command with output directed to a file: #!/bin/sh now=$(date) /bin/sh "$@" 2>&1 | awk -v now="$now" '{ printf("[%s]\t%s\n", now, $0) }' >/tmp/...
Logging all crontab output using MAILTO
1,570,835,992,000
matthew@matthew-pc:~$ crontab -l [...] @reboot 1 5 * sleep 10s && export DISPLAY=:0 && xdg-open ~/@/Testing.jpg "Testing.jpg" was not opened at Linux startup on May 1. How can I use Crontab to open a file at Linux startup on a specific date, e.g. May 2?
You can't mix a schedule with @reboot - cron doesn't support that. If you want to open a file at Linux startup on a specific date, do this: Write a script (chkdate.sh) that checks the date for a match to (for example) May 2 Use the @reboot spec in cron to run chkdate.sh [EDIT: re chkdate.sh, a script to check ...
How do I use Crontab to open a file at Linux startup only on a specific date?
1,570,835,992,000
I have a set of 6 jobs to be run via cron. Let's call them jobs A,B,C,D,E & F 'A' & 'B' take 2 mins to complete, 'C' , 'D' , 'E' & 'F' take 3 min each to complete. No job is dependent on the other The problem of running them all together is a burst of CPU & then everything is idle. I'm looking to space the execution o...
As user Archemar already pointed out in his comment use the utility run-parts. In many Linux distributions this is also used to execute all the cron scripts of severaly system software packages stored in the directories /etc/cron.daily, /etc/cron.hourly and so on. Normally run-parts will execute all your scripts one a...
Work out a cron job schedule
1,570,835,992,000
I'm trying to setup a relatively short shell script called backup_extract.sh which will essentially unzip a zip file, drop a database, create a database of the same name, then import an sql file that was created from the zip file. This zip file is created on a separate server, then transferred to this server every day...
My solution for this may not be the same for everyone but basically crontab -e didn't work AT ALL. I ended up having to edit /etc/crontab. Set the PATH variable to /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin, the SHELL to /bin/bash, then added my cron jobs in that file. Now the cron job is running correctly. I'm...
Cron log shows shell script has run but it really hasn't
1,570,835,992,000
I have a script very similar to the one at the end of the pygame example page, and I want to run it on startup to make the whole thing listen for commands on startup. I ran "crontab -e" and as a first line I put "@reboot python3 myscript.py". Upon rebooting, the script doesn't work, and returns pygame.error: video sys...
If your script runs from the command line, but not from cron, there are two usual suspects: The PATH for cron is different than your path as a "regular" user. You can address that issue by using a full path spec for your script: @reboot python3 /full/path/to/myscript.py cron is unaware of the status of any serv...
X11 and pygame in Crontab
1,570,835,992,000
I have a shell script that gets updates from github and then runs the code that it retrieved. it is located at /home/me/Desktop/refreshCode.sh -- refreshCode.sh -- #!/bin/bash cd /home/me/src/ProductionMonitor sudo /usr/bin git -C /home/me/src/ProductionMonitor pull sudo cp /home/me/src/ProductionMonitor/* /home/me/...
You should probably not sudo all the stuff; all things are under your own directory. The main point of your question is, that your script does not know where to display the window. Try adding echo "DISPLAY=$DISPLAY" >> logfile.data You will probably see DISPLAY= in `logfile.data. Furthermore, if you use: /usr/bin/p...
How to get a shell script to execute correctly on reboot
1,570,835,992,000
I have cron set to run a task for user pi (on my Raspberry Pi running Raspbian Stretch) every 15 minutes. 6,21,36,51 * * * * /usr/bin/mosquitto_sub -h Pi3Plus.local -v -C 1 -t weather >> weather.log I also have ssmtp setup to send email via gmail. Every so often the cron task fails to connect to the server, and gener...
From the crontab manual: In addition to LOGNAME, HOME, and SHELL, cron(8) will look at MAILTO if it has any reason to send mail as a result of running commands in "this" crontab. If MAILTO is defined (and non-empty), mail is sent to the user so named. If MAILTO is defined but empty (MAILTO=""), no mail will b...
Prevent cron sending error messages
1,570,835,992,000
I have some cron tasks, and some of them doesn't stop sending me emails. An example task are: */2 * * * * php app/console mautic:email:fetch > /dev/null 2>&1 (All the tasks with the problem are mautic tasks). I've tried some tricks for avoiding emails: > /dev/null >/dev/null >/dev/null 2>...
The /bin/sh: 1: cannot create 1: Permission denied error is probably because you have a typo in a redirection. Perhaps instead of 2>&1 you have 2>1 or 2>1&. (Normally the attempt to create a file named 1 in your home directory would succeed, but if a file named 1 already exists and is not writable then you'll get th...
Why cron doesn't stop sending emails even redirecting to /dev/null
1,570,835,992,000
I was configuring crontab with user "pi" to execute an sh script every 30 mins. In terminal:crontab -u pi -eI added this line: */30 * * * * /bin/sh /home/pi/test.sh And in the script test.sh there three lines: #!/bin/sh /usr/bin/transmission-gtk echo "done" > /home/pi/startup/result.txt As a result, every 30 minutes...
Apparently, transmission-gtk is some graphical program that you wish to start? In that case, you need to tell cron on which display to start it. Try this in your crontab before your line (assuming you're using display 0): export DISPLAY=:0 You should also have error messages in your mail (probably /var/mail/username)...
execute sh script from crontab problem
1,570,835,992,000
Env:- Ubuntu 18.04 I write one C program and trying to speak to port and fetch some data and dump into one file. Then I created one bash script and added this C program and expect to run at multiple intervals. I'm able to run this bash script without any issues. I'm running as root. <<snip>> #!/bin/bash interval=$1...
The cron daemon is always running as root. The cron jobs will be run as the user whose cronjob they belong to. If you add the cron job with crontab -e as user john, then the job will be running as user john, not as root. To edit root's cron jobs, use sudo crontab -e. The difference between running a command from the...
Bash script able to run manually, but with cron not working. + Ubuntu 16.04
1,570,835,992,000
In my /etc/crontab # /etc/crontab: system-wide crontab # Unlike any other crontab you don't have to run the `crontab' # command to install the new version when you edit this file # and files in /etc/cron.d. These files also have username fields, # that none of the other crontabs do. We can use crontab to edit a user-...
Use your preferred editor. nano and vim are good editors. The 6th field is the username under which the entry should run. EDIT: I have a BSD 4.2 box. I have to export the editor before editing the crontab file on it. EDITOR=vi export EDITOR crontab -e
How would you edit `/etc/crontab` and files under `/etc/cron.d/?
1,570,835,992,000
I am trying to get launchd (which is macOS's alternative for cron) to run a job for me. It doesn't work, while running the commands on a bash launched with sudo does. I tried redirecting the output to files, but examining them hasn't enlightened me, either. I like to have access to this 'primal' environment launchd us...
At the beginning of your script you could do something like env > /tmp/myscriptrun_env.$$ This will put the inherited environment into a file in /tmp. Now from the command line you can use the command env -i /bin/sh to generate a new shell with a fresh environment. Inside this shell you can source the /tmp file you ...
How can I open a shell in the environment that cron (alternatively launchd) uses to execute commands?
1,570,835,992,000
I have this crontab * * * * * tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant It does not work. But if I do tar -czf /backup/$(date +%F--%T)-localusers.tgz /vagrant/ It works. Anybody have a clue what's going on? I do keep getting a mail though: N 10 (Cron Daemon) Thu Aug 23 10:43 28/1130 "Cron <ro...
Your problem is likely because of the cron special treatment of percent sign: The entire command portion of the line, up to a newline or % character, will be executed by `/bin/sh or by the shell specified in the SHELL variable of the crontab file. Percent-signs (%) in the command, unless escaped with backslash (...
Tar crontab not working, while command works on it's own [duplicate]
1,570,835,992,000
I need to make a planned task : Check the available space on the hard disk each day and remove files if this condition is verified : Available < 1Go. Here is the script that I wrote but doesn't seem to work : var="df -h | sed -n 2p |awk '{ print $4 }' " if[var<15];then ./bin/dss stop rm -rf tmp/* rm -rf caches/* ./bi...
try the below code. #!/bin/bash var=$(df -h | sed -n 2p |awk '{ print $4 }') if [ "${var}" le "15" ] then ./bin/dss stop rm -rf tmp/* rm -rf caches/* ./bin/dss start fi
How to check the available space on the hard disk each day and if it is lower than 1GO remove files
1,570,835,992,000
I did write shell script #!/bin/bash #clear #echo "Good morning, world." source activate python36 python /opt/project1/Table_Control.py opt/project1/connection.yaml After I did write in cron # job 1 19 * * * /opt/project1/start.sh and did try else other variant # job 1 19 * * * cd /opt/project1/ && ./start.sh Di...
Usually to debug such issues it might be handy to add some logging, possible for each line. Like this: source activate python36 >> /tmp/1.log 2>&1 python opt/project1/Table_Control.py opt/project1/connection.yaml >> /tmp/2.log 2>&1 You can also set cron task to be be laucnhed every minute so that you don't need t...
Why not working Job start by Cron?
1,570,835,992,000
We are seeing our /var/lib/logrotate/status gets invalid entries like following: saurabh@1236:~$ cat /var/lib/logrotate/status logrotate state -- version 2 "/var/log/syslog" 2018-3-13 "/var/log/auth.log" 2018-3-13 "/var/log/debug" 2018-3-13 "/var/log/lpr.log" 2018-3-13 "/var/log/user.log" 2018-3-13 "/var/log/mail.inf...
There are multiple concurrent instances of logrotate being run by cron jobs on your machine. There is no locking on the state file used, and so the different logrotate jobs "step on each other's toes" when updating it. Since you added your myFile configuration for logrotate in the /etc/logrotate.d directory, you don'...
/var/lib/logrotate/status gets invalid entries
1,570,835,992,000
When I run a cronjob, it's nice being able to follow its logs. If I want to see all logs from cron with journalctl, I can select the cron unit (journalctl -u cron). But when I have multiple cronjobs, it's not very helpful filtering only for the cron unit. Is there some way to filter for a specific cronjob in journalct...
Since these are simply messages from cron, the metadata is all about cron. Example for a couple of messages about a cronjob, using --output=json: { "__CURSOR": "s=74429436aba942b6bbfc70cf45bfecc6;i=188d;b=108f80cdd87342bcb9dcafca15c45b57;m=6c13fcb19;t=5697ae32bb8a9;x=d292b55b7b7a140d", "__REALTIME_TIMESTAMP": "152...
Specify a systemd unit for cronjob
1,570,835,992,000
I want to run a script on startup that establishes a GRE tunnel. The script works fine if I just run /root/tunnel.sh after rebooting, it runs and establishes the tunnel. Below are the contents of my crontab -e for root user on my machine. @reboot sleep 15; /root/tunnel.sh Am I missing something? I'm running CentOS...
/root/tunnel.sh: line 2: ip: command not found Your root login profile (one of ~/.bash_profile, ~/.bash_login, or ~/.profile) is setting $PATH to include /usr/sbin, while your (non-login) script is not setting $PATH to include /usr/sbin. Either expand $PATH in your script or use full paths to programs that are in /u...
What's wrong with my cronjob?
1,570,835,992,000
Content of /var/spool/mail/root: From [email protected] Fri Feb 23 12:40:02 2018 Return-Path: <[email protected]> X-Original-To: root Delivered-To: [email protected] Received: by test.corp.test.biz (Postfix, from userid 0) id 202C12C0A32; Fri, 23 Feb 2018 12:40:02 -0500 (EST) From: [email protected] (Cron Daemon)...
Files in /etc/cron.d/ should be cron entries, not scripts. That's why your previous question, BAD FILE MODE yum-cron, showed cron complaining; it expected a plain text file (not an executable script) containing crontab entries. That's why, for example, I have a file named /etc/cron.d/0hourly which contains: # Run the ...
Permission denied yum-cron
1,570,835,992,000
First of all I am not very familiar with cron... Under .../cron/crontabs I have a file (which is called root, not sure whether it needs to be the same as the user?) with one job: * * * * * sleep 0; wget -0 /var/cache/file.txt 'IP-ADDRESS' * * * * * sleep 10; wget -0 /var/cache/file.txt 'IP-ADDRESS' * * * * * sleep 20;...
Yes, you can have only one crontab per user, and its filename is the username. Also, the proper way to edit it is to run crontab -e -- it's entirely possible that the cron daemon doesn't notice you've changed the file directly. Just call crontab -enow, it will open your editor with the crontab, and it will reload the...
Two Cron jobs at the same time - one not working
1,570,835,992,000
I'm running the following script on @reboot cron with root: autossh -f -i /home/pi/.ssh/myRemote.pem -R 2210:localhost:22 [email protected] When I run manually it works fine but from cron I see it show in the logs continually failing: Nov 25 01:15:56 kirkins autossh[1936]: starting ssh (count 1) Nov 25 01:15:56 kirki...
The reason is probably that ssh does not like the fact that it is started without a controlling terminal (cron children do not have one). You could try ssh -tt. Or run it within screen / tmux.
Auto-SSH works manually but not in background
1,570,835,992,000
I need to be able to start a named "session" from within a cron job and run a job within that named session. The job I need to run MAY cause my appliance to not run properly if problem exist and I need to be able to reattach to the named session created if needed/to close it later. Does anyone have any idea how I migh...
GNU Screen or TMUX are probably your best options. The general concept of both is pretty similar to a tabbed window manager, but they're both for terminal usage, and you can detach from a session and re-attach later. I'm not quite certain about the syntax needed for TMUX, but for screen the command you want is: scre...
Using session command from a cron job (linux)
1,570,835,992,000
By "adjacent cron tasks" I mean to tasks doing things of the same context and in close times. For example, as for now I have these cron tasks: 0 0 * * * for dir in /var/www/html/*/; do cd "$dir" && /usr/local/bin/wp plugin update --all --allow-root; done 0 0 * * * for dir in /var/www/html/*/; do cd "$dir" && /usr/loca...
For anything other than running a simple command, schedule a script that does the complicated processing instead of trying to do it directly in the crontab. #!/bin/sh for dir in /var/www/html/*/; do ( cd "$dir" && /usr/local/bin/wp plugin update --all --allow-root ) done for dir in /var/www/html/*/; do ( cd ...
Is there a best practice to make adjacent cron tasks near in time?
1,570,835,992,000
I have typed for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done And that say no crontab for root no crontab for daemon ... no crontab for apache2 and i got very often You have new mail in /var/mail/root message when i read there are all the same From [email protected] Wed Aug 2 15:40:02 2017 Retur...
When you get mail like From: [email protected] (Cron Daemon) To: [email protected] Subject: Cron <root@lxc2014> /dev/.x;^Mno crontab for root X-Cron-Env: <LOGNAME=root> /bin/sh: 1: ^Mno: not found and you can't tell which crontab contains the offending command, you can grep for pieces of command in the standard plac...
why I get this /bin/sh: 1: ^Mno: not found error
1,570,835,992,000
I'm trying to create my first cron job. I'm new to bash scripting too, although I do know some python. I am puzzled by the following: Here is my cronjob file created with crontab -e: */1 * * * * /home/darren/.bash_scripts/urxvt_colors.sh Contents of urxvt_colors.sh: #!/bin/bash python ~/.Py_Scripts/xr_random_color...
Try to change your script like this #!/bin/bash python ~/.Py_Scripts/xr_random_colors.py && xrdb ~/.Xresources and i recommend you to use full path to files. PS maybe you need to define DISPLAY var while exec script */1 * * * * DISPLAY=:0 /home/darren/.bash_scripts/urxvt_colors.sh
Cronjob executes `/usr/bin/python` but not `usr/bin/xrdb` [duplicate]
1,570,835,992,000
Am using Ubuntu14.04. Server Backup will take place every week. But will this affect the crontab? Because "sudo crontab -e" does not contain the cron job which I gave. Please help! Thanks in advance
Every user has their individual crontab. This includes the root user. When you add a cronjob with crontab -e, you add it into the list of jobs for the current user. This means that with sudo crontab -e, you will be editing the list of cron jobs for the root user. To edit the crontab for a specific user, use sudo cront...
"sudo crontab -e" does not show the cron job which I gave
1,570,835,992,000
I would like to know how to run make a terminal program run automatically at reboot with preset input variables. What I am trying to do is run bro control which is a terminal program that requires input. I know that when you run cron jobs, that are terminal commands, it does not show the terminal screen. I would like ...
Save your desired input into a file, and pass that file as an input argument to the program. my_command --some_flags_if_needed < path/to/file/containing/input
how to run make a terminal program run automatically at reboot with preset input variables
1,493,277,389,000
I have a script from within which I write some text to a file. It works fine if I manually i9nvoke it from the shell but it doesn't seem to work prperly if it's invoked from cron. The file is created but nothing gets written to /tmp/tx_buf. The script looks like: #!/bin/bash declare -i Threshold=1000 tmpfile="/tmp/tx...
You could do some troubleshooting in the following way: Change the script header like this: #!/bin/bash exec 1>/tmp/$0.log 2>&1 set -x ...insert the rest of you script here.... After cron was starting you script you should find a file called /tmp/.log This should give details about what was going on during runtime...
nothing is written to my text file if run from within cron
1,493,277,389,000
I have a script which before being launched checks via pwd if the path upon launch is something specific (say dir/subdir/script) current_folder=$(pwd | grep dir/subdir/script) if [ "$current_folder" == "" ]; then { echo "something bad" exit } fi how can this script be launched via crontab? I cannot remove the check w...
You can specify several commands, separated by ; or &&, as your cron job, for example: * * * * * cd /some/path && foo (This will only run foo if the cd was successful.)
launch a script which requires to be launched from a specific path via crontab
1,493,277,389,000
I have a problem with script scheduled in cron. In cron I have following line: 33 09 * * 1-5 oracle /data1/backup/scripts-test/rman.sh > /data1/backup/log.txt 2> /data1/backup/log_err.txt As you see I have to use oracle user to run rman script. RMAN.SH looks as follow: #!/bin/bash ORACLE_HOME="/data1/app/oracle/prod...
Thomas, possible you must export the variable ORACLE_HOME, by; export ORACLE_HOME after declaration in script: rman.sh
Problem running rman in cron
1,493,277,389,000
i am having a file, which contains usernames and encrypted passwords (openssl passwd) in the format user:password. Now i want to change the password of this User with a Cronjob once a week. With the help of Janos i made a Script, which changes the password to a $RANDOM generated value, and saves the encrypted password...
You can save the generated password in a variable, and write it two files: One file in clear One file hashed For example: # initialize (truncate) output files > clear.txt > hashed.txt cut -d: -f1 pw.txt | while read -r user; do # generate a hash from a random number hash=$(openssl passwd $RANDOM) ...
Password change Script
1,493,277,389,000
I'm maintaining a server which runs mailman. In it I find a crontab which looks like the following: 0 8 * * * list [ -x /usr/lib/mailman/cron/checkdbs ] && /usr/lib/mailman/cron/checkdbs 0 9 * * * list [ -x /usr/lib/mailman/cron/disabled ] && /usr/lib/mailman/cron/disabled ... When I type list I get No command 'lis...
Lines in the system crontab (which is what I think you're looking at) have six fixed fields plus a command, in the form: minute hour day-of-month month day-of-week user command This is different from the per-user crontab which lacks the user field. My guess is that list is the mailman user on that system. This user ...
What does list in crontab do?
1,493,277,389,000
I want a computer (Debian, XFCE) to shutdown every day at a specific time as well as a pop-up window in advance telling about the immanent shutdown with, say OK, Skip and Delay 60 min buttons. I noticed xmessage being installed and it gives an easy way to handle rudimentary pop-ups with defined buttons. But the work...
I think you should consider a slightly different approach: instead of using cron for a shutdown, use cron to display a message with xmessage. Then, after the actions (if any) taken from xmessage events (buttons pressed or not), you initiate a shutdown. In other words: at a certain time, display xmessage via cron if n...
Periodic shutdown with popup-message and skip/delay-button
1,493,277,389,000
Here's a little background as it might be the cause to the problem. I'm running Armbian legacy Jessie on a Orange Pi Zero. It does not include an desktop so I've installed X, lightdm and Xfce. I haven't managed to start X on boot so I have a @reboot line in crontab that executes a script that includes this: #!/bin/ba...
Cron doesn't use /etc/profile. Write the variables at the top of your crontab file.
Why can't I run GUI apps with sudo from crontab when I can with sudo: “No protocol specified”? [duplicate]
1,493,277,389,000
I was wondering if my crontab jobs were written correctly. I am hoping to run them on a VPS and monitoring them isn't really possible. Without further ado here are my cron jobs: # cd into directory at 2:57 AM 57 2 * * 1-5 cd /folder_name # activate the virtual environment 58 2 * * 1-5 . env/bin/activate # run the m...
No, cron is not a shell. Write a script: #!/bin/sh cd /folder_name . env/bin/activate exec python main.py Make it executable, then point a crontab entry to it: 57 2 * * 1-5 /path/to/script The script should then run every Monday to Friday, at 2:57 in (your machine's idea of) local timezone. If you configured your ...
Using Cron/Python
1,493,277,389,000
In my CentOS, i'm trying to print the CPU USAGE and FREE MEMORY output numbers into a text file. But when i typing in the terminal, it is all fine. But when it is executed via the crontab the MEMORY output is always blank. Manually typing in terminal: # echo CPU: `top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}'`, R...
Because dash doesn't understand this kind of bashism: <(free -m) Instead, use: free -m | awk '/^Mem/ {print $4}'
Shell Script (in Crontab) : Saving Memory print into text file always gives blank
1,493,277,389,000
I have a script job.sh in /home/user/scripts, which is then symlinked to /home/user/bin/job. The custom binaries path has been included in .bashrc, so whenever I issue the command job param1 etc from the cli everything works as expected. When said command has to be run through a cronjob, it doesn't. On the other hand,...
cron intentionally runs with a limited environment (including a restricted path, it does not have the same path as your standard shell). You either need to run a script (including the full path to the script) which then sets a path variable internally, or you need to set the path in the crontab line itself. One exampl...
cron not working with commands symlinked in custom PATH
1,493,277,389,000
I am trying to automate backup management on server on raspberry and put a regular tar triggering into a crontab. I set it up via bash scripts. First I set up the task and then use script to carry out expected actions. The problem is the script isn't executed by crontab. When I run the same command as saved in crontab...
I've found an answer in "How Linux Works" by Brian Ward. I've simply messed the syntax. Deleting the passing of $USER fixed the problem. In other words the file file I am passing to crontab should have following structure: m h dm m dw command and not: m h dm m dw user command And again thank you roaima for useful ti...
Crontab task not trigerred
1,493,277,389,000
The timer functionality of systemd includes monotonic timers, which measure time in real uptime since some starting point after boot. This means that after a boot, the service triggered by the timer is started and then the timer fires according to some predefined conditions based on actual uptime, i.e., excluding susp...
No, currently this is not possible. A feature request has been filed: https://github.com/systemd/systemd/issues/3107
cross-reboot monotonic systemd timer
1,493,277,389,000
I have a server at home that I use as a NAS and some other services. The server has Debian Jessie on it, with 4x 4 TB harddrives in RAID5. I use this server to store all my home data, movies, games, etc. About 75% of it is filled. I learned about AIDE some time ago after checking my cron reports, with aide giving an e...
It turns out the solution is to exclude that directory of the array. This is how to exclude it: Just add this line to the config file of aide to exclude the folder /raidarray: !/raidarray/.*
AIDE is taking forever to initialize
1,493,277,389,000
My setuid.today has a different date format than setuid.yesterday: setuid.today (German localization?) 3 Dez setuid.yesterday Dec 3 I'm getting emails with the diff reports every day. I guess one of the periodic scripts changed something during the last update. I'm on FreeBSD 10.2 How should I proceed?
To summarize what we discovered in the comments: At some point (before the upgrade), /etc/login.conf was populated with :lang=de_DE.UTF-8 in the default class. After updating to FreeBSD 10.2, cron was presumably restarted, and picked up the new locale. The new locale caused the date formats inside the setuid.today fil...
setuid.today date format changed after FreeBSD 10.2 update
1,493,277,389,000
I have read a lot of post around this topic but I didn't found the one to fit my needs. So, basically I want to make two backups: one at mid day (12 PM) and the other at midnight (12 AM) for each database on a MySQL server but I want to leave out system databases: mysql and information_schema (as far as I know is ther...
I'm currently using PostgreSQL, and I do something that looks really close to what you want to achieve, so this is my backup script: #!/bin/bash # #------------------------------------------------------------------------------ # Editable parameters: # ## Filesystem Location to place backups. BACKUP_DIR="/path/to/back...
Script for backup each DB on server but omit system databases
1,493,277,389,000
I have a client running on Rackspace, they have three servers that are synced together entirely, I've added a bunch of crons in the crontab using wget to the web address of the cron (that sync to each server). When you go to the client's domain, a load balancer takes care of you. I only want to run the crons once on ...
You have three almost-identically configured servers, but you want to run the cron jobs on only one of them? Let's follow your naming scheme for the servers: web01, web02, and web03. I'm using shell script, but the principle is exactly the same for PHP. (I can throw PHP around but I don't consider myself well-versed e...
Running crons on a scaled mirrored servers (cron logic needed) [closed]
1,493,277,389,000
I while ago I wanted to have messages from cron sent to my mail address so I installed ssmtp. But then I decided that I'd rather receive the messages in the file under /var/mail as usual, so I removed ssmtp. But the messages from cronjobs does not show up under /var/mail now, they seem to be entirely lost? I am using ...
If there is no Mail Transport Agent installed (e.g. Exim, Postfix, Sendmail) then there will be no sendmail binary for cron jobs to interact with, and odds are any messages that were attempted to be sent are lost. You'll need to ensure that a MTA is installed and properly configured.
I lost my mail spool
1,493,277,389,000
Say I have a crontab like: */30 * * * * /root/scripts/remove_log_files.sh This will remove some logs that I don't want every 30 mins. What would happen if the server shutdown after 25 mins the crontab is activated and restarted 10 mins later? Update: according to some searches the job will not be fired. But will the j...
Traditional cron checks every minute if the current time matches one of the time pattern in the crontab and executes every matched lines. There is no notion of "missed jobs" or "jobs running soon" at all. The pattern */30 * * * * matches on timestamps with minutes dividable by 30 (that is 0 and 30). If you want somet...
What would crontab do if the server is shutdown?
1,493,277,389,000
The below line should provide an output date which when run manually gives an proper output such as Fri Jul 17 01:42:07 2015. But when run using cron, it gives the epoch date i.e. Wed Dec 31 19:00:00 1969 job_date=`iwgetwfobj $i | sed -n 2p |tr -s '=' '@'|awk -F'@' '{print $6}'|tr - d \" |tr -d \>| perl -e 'print loca...
The issue was resolved by putting the path before the CLT iwgetwfobj. Thanks for the help.
Output date is not proper when the script is run using cron
1,493,277,389,000
I'm on my freeBSD server. Cronjob suddenly stop working. When I run "top" the service is not listed. But when i check "service cron status" , it is running with given PID. I restarted the service and even server but the problem still persist. How can I troubleshoot this?
You can check this, ps -ef | grep cron
Cron service running but not visible by "top"
1,493,277,389,000
I'm trying to make a script that will run in cron, that will search a path for specific file name. In the path there might be more folders with that same file name. If found and they are newer than 2 days, rsync the parent folder and all content. This part works but only syncs "filename.txt" that is newer than 2 days ...
I'm assuming by parent folder you just mean the folder with filename.txt. You can get find to print this folder name with -printf '%h\n' instead of the -exec. You can pipe this into a shell loop or xargs for example: find /path/ -name "filename.txt" -type f -mtime -2 -printf '%h\n' | xargs -i rsync ... {} /destinati...
Want to use find with rsync in script
1,431,389,242,000
I am hoping to write a cron wrapper that records all output in a folder $CRON_LOG_DIR. It would be used as, e.g., follows: * * * * * $CRON_WRAPPER "<job name>" "command" which would record the full output from stdout and stderr of command under: $CRON_LOG_DIR/<date>/<job_name>/command_timestamp.log I am using the s...
If the first argument to the script is jobname and the second is command1 && command2 && command3 then the command you build up in the joined variable is something like command1 && command2 && command3>> /path/to/cron/log/dir/May_12_2015/jobname_2015-05-12_01-09-25.log 2>&1 You call eval on this string, and it's par...
A generic cron wrapper that records all output
1,431,389,242,000
I am running a cronscript like: */45 * * * * /path/to/php /path/to/file.php it creates a file and put on home directory; But I want to create this file in my desired path like: */45 * * * * /path/to/php /path/to/file.php /path/where/file/to/save actually the file.php create file.xls and put it on home directory. I wan...
If the PHP script creates the file in the current directory, change to the desired output directory: */45 * * * * cd /path/where/file/to/save && /path/to/php /path/to/file.php If the PHP script creates the file in your home directory, you might be able to pretend your home directory is elsewhere — but if it also trie...
How to set path in cronscript
1,431,389,242,000
I am trying to take a db backup with a php file that is running from a cronjob. It was running fine when I tested with sample db. But when I used the actual db there was an error. I am using shell_exec() to run the command from the php file and the error is: sh: -c: line 0: syntax error near unexpected token `)' I und...
After wasting some time I got it working. I just had to escape the character like this: $pass = '\)d@340kgfj';
Having problem with mysql dbdump when password starts with special character
1,431,389,242,000
I found this file tonight: /etc/cron.daily/apt.cron #!/bin/sh [ ! -f /var/lock/subsys/apt ] && exit 0 [ -f /etc/sysconfig/apt ] && . /etc/sysconfig/apt [ $CHECK_ONLY == "yes" ] && OPTS="$OPTS --check-only" OPTS="$OPTS $EXTRA_OPTIONS" export HOME=/root if /usr/bin/apt-get -qq update; then /usr/bin/apt-get dist...
Try this: rpm -qf /etc/cron.daily/apt.cron That's the rpm command which tells you which package a file comes from (if any). In this case, the file comes from the apt package, which you have installed on your system for some reason. This is the "apt-rpm" port, which, as the name implies, can handle Fedora's RPM packag...
Why is there an apt-get script set in my cron.daily, I'm on Fedora 20?
1,431,389,242,000
It sounds really simple, but many times I was stuck at the beginning of learning a new command. The tutorial writer think it's natural to start, but it's not. This is the tutorial I've been reading: http://code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800 After reading that, I started something l...
crontab -e it will open a configuration file in editor and you then add your line to the end: * * * * * /usr/bin/sh t.sh
How to start a cron task?
1,431,389,242,000
I am running Fedora 20 and I am having some issues when running logrotate and anacron which I suspect may be related to SELinux: Failed to determine timestamp: Cannot assign requested address chgrp: changing group of /var/log/mariadb: Permission denied I did some research and came across this article from Gentoo wiki...
It seems that this is how it should be: From changelog of selinux-policy-3.12.1-139: - Allow systemd_cronjob_t to be entered via bin_t Do you have any errors in /var/log/audit/audit.log pertaining to mariadb? A quick and easy check is to setenforce=0 and run your cron jobs. If they fare better then it was SELinux ...
What should be the security context of these cron files?
1,431,389,242,000
This weekend with daylight savings, we had a situation that when the system clock hit 3:00am from the jump, we had hundreds of processes fire off out of the crontab. Everything I'm reading says that if you schedule processes during this time and you're running the system in the local timezone, then you may have script...
It looks like this was a bug in the version of crond that we were running documented here: https://bugzilla.redhat.com/show_bug.cgi?id=436694 I was able to replicate in a VM upgrading to 1.4.4-12 fixed the issue. Thanks for all the replies!
Crontab in Daylight Savings
1,431,389,242,000
I have some cron jobs set up to run, some of them each minute. I know I can log them to text files by simply putting php /path/to/file.php > /var/logs/something.txt but can I do this every minute? The nature of the log's output means that the log file will be very small, but I don't know how to log each minute's outp...
You can pipe the output to cronolog for log file time handling. For documentation see Cronolog Usage and download Cronolog at Sourceforge General example command "|/path/to/cronolog [OPTIONS] logfile-spec" where logfile-spec for you could be /var/log/cmdOutput_%Y_%m_%d_%H_%m.log
Cron Job - Log Each Minutes Activity [duplicate]
1,431,389,242,000
Here is my crontab: # rsnapshot jobs 0 9-21 * * * /usr/bin/rsnapshot -c /home/kaiyin/.rsnapshot.conf hourly 52 22 * * * /usr/bin/rsnapshot -c /home/kaiyin/.rsnapshot.conf daily 42 22 * * 6 /usr/bin/rsnapshot -c /home/kaiyin/.rsnapshot.conf weekly 32 22 1 * * /usr/bin/rsnapshot -c /ho...
System crontabs If these are system level crontab entries (/etc/crontab), then they're missing the username they should be running as. # For details see man 4 crontabs # Example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | |...
Why don't these cron jobs run?
1,431,389,242,000
I've just installed the 'mail' command in Ubuntu (mailutils package) in order to view feedback from cron jobs. I type 'mail' at the prompt and see something like this: "/var/mail/*$USER*": 1 message 1 unread >U 1 *Name* *Date* Output from your job I type 1 at the ? prompt and get a lot of output about the message (F...
The mail program opens emails in a pager. The environment variable PAGER can override the default pager, which is typically less. In Debian-based systems, there is a /usr/bin/pager that is managed by the alternatives system. You need to ensure that your pager is not a GUI application, which would require X. An easy wa...
Linux 'mail' command: Can't open display
1,431,389,242,000
I'm trying to send cron output to an email address and am struggling... I'm running the following command: 13 15 * * 1-5 root /path/to/mysql-backup.sh 2>&1 | mail -s "Daily Database Backup Report" [email protected] That shows this error within /var/mail/root /usr/bin/mail: line 1: syntax error near unexpected token `...
In my experience, /usr/bin/mail is a binary executable, but on your system the shell seems to be loading and interpreting it. syntax error near unexpected token is a bash diagnostic. This can happen if you have overwritten an executable. Is there any conceivable chance that you have overwritten /usr/bin/mail with the ...
Sending cron output to email?
1,431,389,242,000
I'm trying to create an interface that will show a message on the screen every set time. Cron is an ideal tool for this case only it doesn't read data from a file during it's run (as far as I could tell). I could create a bunch of file to read but this is redundant. Is there a way to add a line into the user crontab ...
You can always write a cronjob that calls a script that conditionally calls crontab -l > oldcrontab and then executes crontab file. Where file would be the new crontab that should be installed, constructed from oldcrontab modulo an appended/removed line.
Is there a way to combine a file with crontab?
1,431,389,242,000
So I built an MLB scoreboard with a RPI 3. Right now the display can either show my favorite teams playing, OR all the teams playing and cycle through them as they are going on. I would like to add a toggle switch to the back of the scoreboard to select either the All-Teams or My-Teams depending on who's playing at th...
So first off: you're doing GPIO things in your python script. Honestly, you should just use the very same library you use there (which I don't know) to read the GPIO state and behave accordingly! Same for your do python… ; sleep 10; done loop: this would really be something you should rather integrate in your python s...
How to read a pin state on a Raspberry Pi and select (either/or) between two entries in a cron file?
1,431,389,242,000
I have an odd problem with my Debian server. Up until a few weeks ago, anacron was running my cron jobs fine and I can see I have backups from then so it was running stuff. Then it appears to have just stopped running cron tasks in /etc/cron.daily/weekly/monthly. The logs, however, don't show any issues. Here's m...
OK, I just discovered (thanks to this) that run-parts ignores files/links that have an extension; it doesn't match the . character. No idea why. Changed my symlinks in /etc/cron.daily not to have the .extension and now they run. Crazy.
Anacron doesn't appear to run anything on Debian, but why? [duplicate]
1,431,389,242,000
so I want to backup my system drive (full drive not just partition) every month using dd, in an external hard drive. So I have something like this in my crontab 0 9 1 * * dd if=/dev/sda | gzip -c > /mnt/5E13119070E2D202/Backups/system_drive.backup.img.gz And that works fine. But I am trying to figure out how to rep...
But I am trying to figure out how to replace /dev/sda (system drive) with something which is persistent between reboots. So, you need a "world wide unique name" for your whole disk. Luckily, Linux has you covered. Find out the unique name for your drive by finding the right wwn-* entry in /dev/disk/by-id. You could...
using a cron job to automatically backup the same drive using dd
1,689,071,548,000
I have a simple shell script that I am running via cron. I am using it to perform a scheduled git pull operation (yeah, I know there are probably better methods, but this is another team's repository and I just need to periodically read from it, so I'm opting for a quick and dirty solution). Anyway, my script does som...
The working directory is a property of the process, so an external binary like /usr/bin/cd can't change the shell's working directory. (It'll just change its own working directory and then exit.) You need the shell's builtin one, which you get when using just cd. Yes, one might sensibly ask "What is the point of the c...
Using '/usr/bin/cd' in a cron script fails while 'cd' works
1,689,071,548,000
I am running OpenSUSE 15.4 and I am trying to set up a CRON job using crontab -e. Inside my CRON tab I have the following: */1 * * * * /usr/bin/Rscript /run/media/matt/A34E-C6B8/folder/myRScript.R So I give it the full path the where the RScript program can be found and then the location of the RScript I want to exe...
Adding >> /home/myuser/myscript.log 2>&1 to the end of the crontab line saves a log of the R code and now I see that I have the following error in the R code which is why I was getting no output! Could not open chrome browser. Client error message: Summary: UnknownError Detail: An unknown server-side error o...
Fixing a cronjob issue when running a script and cron task being deactivated [duplicate]
1,689,071,548,000
I have this command which runs properly when executed on terminal: ssh someuser@someserver -t "sudo systemctl start someservice" No password asked for ssh, there is a public key to connect, someuser can execute sudo to start someservice without password. I need to insert the above command to crontab. Unfortunately it...
As I originally suspected, the problem was ssh -t. The solution, I added this in /etc/sudoers on the SSH server side: Defaults:someuser !requiretty I can't tell what is requiretty used for. To be on the safe side I disabled it for a user only, not globally. It doesn't seem to affect this user in other aspects.
sudo through ssh on cron
1,689,071,548,000
I have an old iMac running macOS Catalina. I've scheduled 2 CRON jobs, one running in the morning (say, 8am) and one running in the afternoon (say, 5pm). The CRON jobs run a few R scripts, in case that matters. Given that CRON jobs won't execute if the machine is sleeping, I'm wondering what's the best way to make sur...
Apple intents to phase out cron (but this is going on for such a long time that I forgot when they first announced this :-)). Nevertheless, using launchd instead would solve your problem quite easily. From man launchd.plist: StartCalendarInterval <dictionary of integers or array of dictionaries of integers> This opti...
Wake up / CRON on Mac
1,689,071,548,000
I'm using crontab to send messages to all users. I wrote */1 * * * * wall $(bash some_shell_script.sh) But the problem is I always have to press Ctrl+D to end the message. How can I solve this??
The wall command executes within the context of cron. It does its thing and exits. On the receiving display devices (terminals) you will get the notification from wall. This notification cares nothing about what you are doing on the terminal, so if you are quietly sitting at a command line prompt when the notification...
How to exit "wall" without pressing Ctrl+D? [closed]
1,689,071,548,000
I would like to run a CRONTAB job to delete files older than 5 days in a folder AND pipe the command output to a file in case of errors. This command deletes the files when run from a command line: /usr/bin/find /mnt/SQL_Backups/* -mtime +5 -exec rm {} \; but, when I add this to it to get the the stdout and stderr p...
stderr to stdout is redirected with 2>&1, not 2>$1 as in your example.
Pipe command output from a CRONTAB job deleting files more that 5 days old [closed]
1,689,071,548,000
As root, I installed ssmtp and I configured the /etc/ssmtp/ssmtp.conf as follows: # Sender email address [email protected] # Destination SMTP server and port mailhub=mail.domain.com:587 # Username and password [email protected] AuthPass=password # Sender domain rewriteDomain=domain.com # Machine's hostname hostnam...
You have inverted the meaning of FromLineOverride. Here with it set to yes you are declaring that the sender is allowed to override the settings defined in ssmtp.conf, and this is why the sender is ending up as root. Switch that setting off (no) and you should be good to go.
crontab error - SSMTP - 553 5.7.1 Sender address rejected: not owned by user
1,650,577,026,000
I've set anacron to run several tasks, but it seems to fail due to some sort of weird permissions error. This is my anacrontab: # /etc/anacrontab: configuration file for anacron # See anacron(8) and anacrontab(5) for details. SHELL=/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # the maximal random delay add...
My anacron worked earlier but doesn't work any more, so I decided to take a different approach. To be able to run it without escalated privileges, you will need to do as follows: Create an .anacron folder in your home dir and two subdirs (etc and spool) by using the command mkdir -p ~/.anacron/{etc,spool}. Create a n...
Why doesn't anacron run the tasks scheduled?
1,650,577,026,000
I have a Bash script which should only execute in a specific time window (from midnight to 00:15 AM). But if I execute the function, I get [: too many arguments as an error message. How do I solve it? I still want to use Bash. I'm using Ubuntu Server 20.04 LTS. Script: currTime=`date +%H%M` check_time_to_run() { t...
You can try to break up your statements: if [ $tempTime -gt 015 ] && [ $tempTime -lt 0 ]; then stuff... fi or use the double bracket to test for the a binary result of an expression: if [[ $tempTime -gt 015 && $tempTime -lt 0 ]]; then stuff... fi
How to do math in If-Statement
1,650,577,026,000
I have this entry in cronjob: $ cronjob -l * * * * * $(cd /home/fedor/Documents/mecab_natto && bash run_mecab.sh >> /home/fedor/Documents/mecab_natto/log.txt) when I run the script manually everything works perfectly fine from everywhere in system. However, when I run it as cron job, the job starts, but terminates im...
Adding #!/bin/bash to the top of run_mecab.sh and calling with: * * * * * $(cd /home/fedor/Documents/mecab_natto && ./run_mecab.sh >> /home/fedor/Documents/mecab_natto/log.txt) instead of * * * * * $(cd /home/fedor/Documents/mecab_natto && bash run_mecab.sh >> /home/fedor/Documents/mecab_natto/log.txt) solved my iss...
Cron job terminates session immediately
1,650,577,026,000
I have read similar posts here, here, here and here that mentioned some environment variables DISPLAY and DBUS_SESSION_BUS_ADDRESS. Setting them at the top of my user crontab enabled notify-send to work in my user crontab. However, the exact same crontab does not work if set in the sudo crontab -e, why not? And how ca...
D-Bus checks whether UIDs of the calling process and the session daemon are the same. Your script needs to run notify-send as the target user. If you insist to run the script as root then in the script you need sudo -u user notify-send …. Keep in mind sudo sanitizes the environment, so DBUS_SESSION_BUS_ADDRESS from th...
sudo crontab notify-send doesn't work
1,650,577,026,000
I have a small script (basically very easy this is the first I wrote) and likes to know the elapsed time, how long it takes when it is finished. Is it possible to count the difference between the two variable? ($SSS and $EEE), I did try with the $SECONDS as well but it gives 0 as a result. Probably a different way nee...
The issue with your script has nothing to do with the timing of the commands. The issue with your script is that it is running in an environment which is different to the environment you run it in from your command line. For example, the PATH variable may be different leading to some utilities not being found, or the...
Elapsed time counting
1,650,577,026,000
Whenn I run sh /opt/script/cypress.sh Everything works, the script changes directory and executes a command to open another script. But when I have my crontab like this 1 * * * * /opt/script/cypress.sh It doesn't work. I edited the crontab with "crontab -e" and tested if it works with a touch command The cypress.sh...
What worked for me is the following configuration: crontab: 0 4 * * * /opt/script/cypress.sh > /opt/log cypress.sh: #!/bin/sh . $HOME/.bashrc cd "/opt/Website Testing/" && "/opt/Website Testing/node_modules/.bin/cypress" run --record --key * Thanks for your help, the ". $HOME/.bashrc" was missing for me.
How do I run a shell script which runs another script with cron? [duplicate]
1,616,862,924,000
have removed jobs from crontab but somehow it's still running at the scheduled time. I am really not sure what to do. Below I have also removed user crontab with: sudo crontab -r -u USERNAME $sudo ls -l /var/spool/cron/ total 4 -rw-------. 1 root root 121 Jan 7 02:28 root This is user's crontab which is empty: $cro...
Finally FIGURED OUT!!!!!! Our internal team had cloned our server to UAT environment which created a copy of all jobs/crontab etc. Thanks for all the help.
Removed jobs from user Crontab but still its running
1,616,862,924,000
I've built a program and I want to run it every 5 mins at round time (**:00, **:05, **:10, ..., not **:01, **:06, **:11, ... or **:03, **:08, **:13, ...). As I've read, it's better to use systemd than crontab, so I want to use systemd. And I understand how to launch program every 5 mins, but it doesn't launch at round...
I don’t think there’s a nice shortcut, but you can do this by listing the possible times in OnCalendar=: OnCalendar=*-*-* *:0,5,10,15,20,25,30,35,40,45,50,55:00 in normalised form. systemd usually allows itself a minute of leeway on calendar events; you can tighten this by specifying AccuracySec=.
systemd - run command every 5 mins and at round time (**:00, **:05, **:10, ...)
1,415,303,231,000
[rootSERVER ~]# rmmod -f cifs ERROR: Removing 'cifs': Resource temporarily unavailable [rootSERVER ~]# modprobe -r cifs FATAL: Module cifs is in use. [root@SERVER ~]# lsb_release -a LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch Distributor...
/usr/bin/sudo /bin/umount -f -a -t cifs /usr/bin/sudo /bin/umount -f -l -a -t cifs sleep 5 /usr/bin/sudo /sbin/modprobe -r -f cifs pkill nautilus
How to remove kernel module if it's still in use?
1,415,303,231,000
Not so much asking what books (although if you know of any guides/tutorials that'd be helpful) but what is the best way to start doing kernel programming and is there a particular distribution that would be best to learn on? I'm mostly interested in the Device Drivers portion, but I want to learn how the Kernel is set...
Firstly: For the baby stages, writing various variations on "hello world" modules, and virtual hardware drivers, are the best way to start (real hardware introduces real world problems best faced when you have more of an idea what you are doing). "Linux Device Drivers" is an excellent book and well worth starting with...
Best way to get into Kernel programming?
1,415,303,231,000
My kernel keeps panicking when connected to a certain wireless network. I'd like to send a bug report but my kernel is apparently tainted. From /var/log/messages: Apr 17 21:28:22 Eiger kernel: [13330.442453] Pid: 4095, comm: kworker/u:1 Tainted: G O 3.8.4-102.fc17.x86_64 #1 and [root@Eiger ~]# cat /proc/...
Well I don't believe a standard Fedora kernel package will include any modules which would trigger this taint so the question is, what other kernel modules have you installed? Common candidates would be graphics drivers (though I think those will mostly set the "proprietary" bit) and wireless drivers. If you can find ...
How to determine which module taints the kernel?
1,415,303,231,000
I have installed vitualbox on Debian Jessie according to instructions on debian wiki. By running: apt-get install linux-headers-$(uname -r|sed 's,[^-]*-[^-]*-,,') virtualbox During installation some errors were reported. Now I want to re-configure virtualbox-dkms but I receive this error: Loading new virtualbox-4.3.1...
I did all of these solutions but problem was about my kernel! linux-headers-uname -r wanted to install 3.16.0-3 headers due to my kernel version but there is no such linux kernel header in Debian repos: There is 3.16.0-4 Solution: upgrade my kernel via apt-get then everything works fine.
cannot reconfigure virtualbox-dkms