I have a file:  -rw-r--r-- 1 michal michal 1679 Apr 24 06:55 acx.php   The owner file acx.php is user michal, so I create cron using:  sudo crontab -u michal -e   My cron:  */10 * * * * php /var/www/html/cron/exchange/acx.php   In log cron I see:  Apr 25 04:10:01 savecoin CRON[9722]: (michal) CMD (php /var/www/html/cron/exchange/acx.php)   I change the permission file acx.php on 777, but it did not help. When I run the cron manually, the data correctly saves to the database. I do not know what else I can change so that cron can write data to the database  I use php7.2, apache2 http server and MySQL database.
27545
There is a Cron job on Ubuntu 16.04 which runs a PHP script  $parseinfo = 'parseme.json'; $handle = fopen($parseinfo, 'w'); fwrite($handle, json_encode($res));   to parse data into a JSON file. The PHP script is supposed to write data within the same folder where this PHP script is located in but I've faced a problem that JSON is being saved into root's home directory:    This is how I set Cron job:  */10 * * * *  root    /usr/bin/php    /var/www/somederictory/somefolder/parse.php &gt; /dev/null   From terminal:  ssh root@example.com cd /etc crontab -e :x   In short words: JSON is being saved into /root while I want it to be saved into /var/www/somederictory/somefolder/ What should I do to fix it?  Edit: It is not a duplicate, PHP works, JSON is being saved, but in a wrong way. And I'm asking to help me understand what's wrong with current Cron settings.
36900
The following command works from prompt but not from crontab.   grep abc  /var/log/messages | grep "`date '+%B %d'`" | mail -s"abc log of `hostname`" shantanu.oak+`hostname`@gmail.com   I need to add it to daily cron.
120554
I am trying to run a simple echo script via crontab. I set that to run every minute, but it doesn't give output on shell screen. However, it runs fine when I run the script independently.   Script  #!/bin/bash echo "Test Script"   Crontab entry:  root@example-server ~]# cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/     # For details see man 4 crontabs  # Example of job definition: # .---------------- minute (0 - 59) # |  .------------- hour (0 - 23) # |  |  .---------- day of month (1 - 31) # |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ... # |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat # |  |  |  |  | # *  *  *  *  * user-name command to be executed   *  *  *  *  * root /root/test.sh
21713
I have Anacron set up to run a backup daily, weekly and monthly. The monthly seems okay, but the daily and the weekly are running roughly every half hour every day! Here is my /etc/anacrontab # /etc/anacrontab: configuration file for anacron                                                                                                                                                                            # See anacron(8) and anacrontab(5) for details.                                                                                                                                                                              SHELL=/bin/sh                                                                                                  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin                                              HOME=/root                                                                                                     LOGNAME=root                                                                                                                                                                                                             # These replace cron's entries                                                                                 1       5       cron.daily      run-parts --report /etc/cron.daily                                             7       10      cron.weekly     run-parts --report /etc/cron.weekly                                            @monthly        15      cron.monthly    run-parts --report /etc/cron.monthly                                                                                                                                           # PERIOD        DELAY   IDENTIFIER      COMMAND                                                                @daily  3       Rsnapshot_daily /root/scripts/rsnapshot_launcher.sh daily                                      @weekly 15      Rsnapshot_weekly        /root/scripts/rsnapshot_launcher.sh weekly                             @monthly        30      Rsnapshot_monthly       /root/scripts/rsnapshot_launcher.sh monthly  I've checked /var/spool/anacron/Rsnapshot_daily and it has todays date in it and was last updated less than 30 minutes ago. It's now 6pm and the daily Rsnapshot task has been run 11 times today and the weekly 10 times so far. What could be going on here? Thanks. (this is on Kubuntu 20.04 LTS)
123578
To backup the "/home" directory tree of a server, I've created a 'backup' account and used setfacl to make the whole directory readable by it. My cron job runs this command as root each night:  setfacl -R -m u:backup:rx,d:u:backup:rx /home   Great, except for one problem: whenever I run this command, it changes the group permissions of my ssh key.  me@myserver:~/.ssh$ ls /home/me/.ssh/id_rsa -l -rw-r-x---+ 1 me me 1679 Jan  8 18:35 /home/me/.ssh/id_rsa   Well, this causes my ssh program to barf because it is now group readable. Strangely, getfacl disagrees with the permissions.  me@myserver:~/.ssh$ getfacl /home/me/.ssh/id_rsa getfacl: Removing leading '/' from absolute path names # file: home/me/.ssh/id_rsa # owner: me # group: me user::r-- user:backup:r-x group::--- mask::r-x other::---   getfacl thinks the file is not group readable. If I run the obvious command  chmod 400 id_rsa   the permission is fixed, but reverts every time I re-run the original command (setfacl -R -m u:backup:rx,d:u:backup:rx /home). What's going on?  Note: I do want my id_rsa to backup up, so let's not worry about those security implications.
104641
I have a deployment script, it must add something to a user crontab (trigger a script that clean logs every XXX days), however this must only be done during the first deployment, or when it needs to be updated.  (I can run xxx.py deploy env or xxx.py update env)  so I have to do this:  Check if my cronJob already exist Put my cronJob if it does not already exist or update my cronjob if one of the parameter of the command is different   I don't see how to add/check/remove something to the crontab without using crontab -e or editing the crontab file (download it, rewrite it, re-upload it)  PS : this is a user specific cronjob, "webadmin" is going to do it and he should not use sudo to do it.
117625
I store backups of databases in a directory structure  year/month/day/time/backup_name  an example would be   basics_mini/2012/11/05/012232/RATIONAL.0.db2inst1.NODE0000.20110505004037.001 basics_mini/2012/11/06/012251/RATIONAL.0.db2inst1.NODE0000.20110505003930.001  note that timestamp from the backup file cannot be used. Before the automation testing starts the server time is set to 5.5.2011  So the question is how I can get the latest file if I pass the "base directory" (basics_mini) to some function that I am going to code.  I need to restore the newest database. I do that in php but I wonder if there is a simple shell scripting solution.
119671
I've basically re-written the terminal output instead of appending a series of edits to this question:  root@doge:/etc/cron.d#  root@doge:/etc/cron.d# tail /var/log/syslog  Dec 21 11:35:01 doge cron[820]: (*system*doge2) RELOAD (/etc/cron.d/doge2) Dec 21 11:35:01 doge cron[820]: Error: bad username; while reading /etc/cron.d/doge2 Dec 21 11:35:01 doge cron[820]: (*system*doge2) ERROR (Syntax error, this crontab file will be ignored) Dec 21 11:38:01 doge cron[820]: Error: bad command; while reading /etc/cron.d/doge3 Dec 21 11:38:01 doge cron[820]: (*system*doge3) ERROR (Syntax error, this crontab file will be ignored) Dec 21 11:56:01 doge cron[820]: Error: bad command; while reading /etc/cron.d/doge4 Dec 21 11:56:01 doge cron[820]: (*system*doge4) ERROR (Syntax error, this crontab file will be ignored) Dec 21 11:56:01 doge cron[820]: (*system*doge) RELOAD (/etc/cron.d/doge) Dec 21 11:56:01 doge cron[820]: Error: bad command; while reading /etc/cron.d/doge Dec 21 11:56:01 doge cron[820]: (*system*doge) ERROR (Syntax error, this crontab file will be ignored) root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat doge * * * * * /home/digger/webxass root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat doge2 * * * * * /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O &lt;user&gt;.&lt;worker&gt;:&lt;worker_password&gt;  root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat doge4 * * * * * /home/digger/webxass root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat /home/digger/webxass  /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O &lt;user&gt;.&lt;worker&gt;:&lt;worker_password&gt; root@doge:/etc/cron.d#  root@doge:/etc/cron.d#  root@doge:/etc/cron.d# /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O &lt;user&gt;.&lt;worker&gt;:&lt;worker_password&gt; [2013-12-21 11:57:09] 1 miner threads started, using 'scrypt' algorithm. [2013-12-21 11:57:09] Starting Stratum on stratum+tcp://doge.pool.webxass.de:3333 [2013-12-21 11:57:09] Stratum detected new block [2013-12-21 11:57:11] thread 0: 4104 hashes, 6.24 khash/s [2013-12-21 11:57:43] Stratum detected new block [2013-12-21 11:57:43] thread 0: 211512 hashes, 6.46 khash/s [2013-12-21 11:58:43] thread 0: 387384 hashes, 6.47 khash/s [2013-12-21 11:58:48] Stratum detected new block [2013-12-21 11:58:48] thread 0: 32964 hashes, 6.47 khash/s ^C root@doge:/etc/cron.d#  root@doge:/etc/cron.d#  root@doge:/etc/cron.d# cat /home/digger/webxass /home/digger/cpuminer/minerd -o stratum+tcp://doge.pool.webxass.de:3333 -O &lt;user&gt;.&lt;worker&gt;:&lt;worker_password&gt; root@doge:/etc/cron.d#  root@doge:/etc/cron.d# su digger digger@doge:/etc/cron.d$  digger@doge:/etc/cron.d$ /home/digger/webxass  [2013-12-21 11:59:51] 1 miner threads started, using 'scrypt' algorithm. [2013-12-21 11:59:51] Starting Stratum on stratum+tcp://doge.pool.webxass.de:3333 [2013-12-21 11:59:51] Stratum detected new block ^Cdigger@doge:/etc/cron.d$    There's some sort of syntax error, but I don't know what it is.    I really don't understand the "bad username" error, digger is a valid user.  Which username is bad?  The digger username in the system?
13403
I have a tiny script that simply fetches the current date, runs a PHP script and redirect the output (and errors) to a filename containing the current date.  DATE=$(date +"%Y%m%d") FILE="log/${DATE}.log" php -q script.php &gt;&gt; $FILE 2&gt;&amp;1   When I run this script on my local machine (Windows 7, Aptana IDE), the PHP script works fine and the logfile has the expected filename, e.g. 20140502.log.  But when I push that script via SFTP to my remote machine and execute that script, the filename looks like this:  20140502?.log?   What might be the problem? Is this an enconding error (e.g. encoding for SFTP uploads is ANSII, where UTF-8 is expected)? Or do I have to change anything in the script itself?  Information about system/shell:  [foo@bar path]$ sh --version GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)   Funny fact: If that script is called by a cronjob, the question marks don't occur. Only if I manually run the script.
116945
I have defined "SHELL" variable in /etc/crontab file:  [martin@martin ~]$ grep SHELL /etc/crontab  SHELL=/usr/local/bin/bash [martin@martin ~]$ file /usr/local/bin/bash /usr/local/bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), dynamically linked (uses shared libs), for FreeBSD 8.0 (800107), stripped [martin@martin ~]$    In addition, all my scripts in /etc/crontab file are started under user "martin". However /home/martin/.bash_profile(for login shell) and /home/martin/.bashrc(for non-logging shell) contain some variables which are ignored in case of cron job, but are used in case I log into machine over SSH or open new bash session. Why cron ignores those variables? Isn't cron simply executing "/usr/local/bin/bash my-script.sh" with permissions for user "martin"?
106013
If script is running fine from command line then, why the same script becomes zombie state after running through cron and How you will troubleshoot the same ?  Here following real example :  [root@abc ~]# ps ax | grep Z 23880 ?        Zs     0:00 [checkloadadv.sh] &lt;defunct&gt; 23926 pts/0    S+     0:00 grep Z [root@abc ~]# strace -p 23880 attach: ptrace(PTRACE_ATTACH, ...): Operation not permitted [root@abc ~]# pstree | grep  checkload init-+-crond---crond-+-checkloadadv.sh [root@abc ~]# bash /usr/bin/checkloadadv.sh System Load is OK : 0.05
25307
Sorry for the basic question - I'm a .NET developer and don't have much experience with LAMP setups.  I have a PHP site that will allow uploads to a specific folder. I have been told that this folder needs to be owned by the webserver user for the upload process to work, so I created the folder and then set permissions as such:  chown apache:apache -R uploads/ chmod 755 -R uploads/   The only problem now is that the FTP user can not modify the uploaded files at all.  Is there a permission setting that will allow me to still upload files and then modify them later as a user other than the webserver user?
16096
I was going to change the ownership of a directory to apache:apache, but I ended up running:  chown -R apache:apache /   Bad! Very bad! I knew what was going on when it started saying:     chown: changing ownership of `/proc/2694/fd/48': Permission denied   That's when I stopped everything (Ctrl+C).    The current system I have is a server running virtualbox running CentOS 5. This problem happened inside the VM.  Currently, everything seems to be working, but I have not restarted the system yet, and to be honest, I'm afraid that if I did something will break.  I do not know chown's order, should I be concerned and assume something will break after a reboot? Is there a way to recover form this problem without having to rely on backups? I do have a daily one, but I thought there may be a simpler way out.
12107
How can I create a scheduled task to run a PHP file? Yes, I filled out everything in the scheduled task, but it still doesn't work.  Run: &quot;C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\WEB\4w_website\save.php&quot; Start in: &quot;C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\WEB\4w_website&quot;  It just opens the PHP file in Notepad. I gave the correct user name and pwd. Please help me..
105330
I have a file named file.txt with some contents located in /home/myuser directory and I change the permissions of that file to root.root and 644.   -rw-r--r-- 1 root root 1.4K Jan 15 07:09 file.txt   Then I switched to myuser and opened it with vim(without sudo) and tried to edit and save it :wq! and I got output like:  "file.txt" E949: File changed while writing Press ENTER or type command to continue   Then I hit enter and then again :wq! and the output was :  WARNING: The file has been changed since reading it!!! Do you really want to write to it (y/n)?   I hit y, the file got saved and exit from vim.  The question is why a file with ROOT privileges and read-only access for a user changed by the way?  PS: 1. myuser is a sudo user.   The user permissions after saving the file changed to myuser.myuser as well.  -rw-r--r-- 1 myuser myuser 1.4K Jun 27 18:57 file.txt
116444
I have tried to make this task for abacron:  dm@dm-system:~$ cat /etc/anacrontab  # /etc/anacrontab: configuration file for anacron # See anacron(8) and anacrontab(5) for details.  SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin HOME=/root LOGNAME=root  # These replace cron's entries 1   5   cron.daily  run-parts --report /etc/cron.daily 7   10  cron.weekly run-parts --report /etc/cron.weekly @monthly    15  cron.monthly    run-parts --report /etc/cron.monthly @daily 5 /home/dm/Devel/btsync &amp;&amp; notify-send "Btsync loaded (pid `pidof btsync`)" "Link &lt;a href='http://0.0.0.0:8888/gui/'&gt;here&lt;/a&gt;."   this command well done from my xubuntu terminal   /home/dm/Devel/btsync &amp;&amp; notify-send "Btsync loaded (pid `pidof btsync`)" "Link &lt;a href='http://0.0.0.0:8888/gui/'&gt;here&lt;/a&gt;."   but when i started my notebook i saw in /var/syslog:  Aug 14 10:49:06 dm-system anacron[904]: Anacron 2.3 started on 2014-08-14 Aug 14 10:49:06 dm-system anacron[904]: Invalid syntax in /etc/anacrontab on line 14 - skipping this line Aug 14 10:49:06 dm-system cron[841]: (CRON) INFO (pidfile fd = 3) Aug 14 10:49:06 dm-system cron[998]: (CRON) STARTUP (fork ok) Aug 14 10:49:06 dm-system cron[998]: (CRON) INFO (Running @reboot jobs) Aug 14 10:49:07 dm-system anacron[904]: Will run job `cron.daily' in 5 min. Aug 14 10:49:07 dm-system anacron[904]: Jobs will be executed sequentially Aug 14 10:54:04 dm-system anacron[904]: Job `cron.daily' started Aug 14 10:54:05 dm-system anacron[2616]: Invalid syntax in /etc/anacrontab on line 14 - skipping this line Aug 14 10:54:05 dm-system anacron[2616]: Updated timestamp for job `cron.daily' to 2014-08-14
92245
I want to be able to programatically add a new cron job, what is the best way to do this?  From , it seems I could dump the current crontab and then append a new one, piping that back into crontab:  (crontab -l ; echo "0 * * * * wget -O - -q http://www.example.com/cron.php") | crontab -   Is there a better way?