I'm trying to add a line export TMOUT=50000 to a file /backup/backup.sh using Ansible.
Below is my playbook:
- name: Add Timeout Entry if not present
lineinfile:
path: "/backup/backup.sh"
insertbefore: BOF
state: present
line: 'export TMOUT=50000'
Getting the below error for ansible playbook:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OSError: [Errno 18] Cannot link to a file on another device.: b'/tmp/tmphtvszlfc' -> b'/wd/backup.sh'
fatal: [10.9.16.133]: FAILED! => {"changed": false, "msg": "The destination directory (/wd) is not writable by the current user. Error was: [Errno 13] The file access permissions do not allow the specified action.: b'/wd/.ansible_tmp3yhi8j7bbackup.sh'"}
Below is the drive information of the target server:
df -k
Filesystem 1024-blocks Free %Used Iused %Iused Mounted on
/dev/hd4 6291456 3323144 48% 42948 6% /
/dev/hd2 6684672 3028820 55% 54304 8% /usr
/dev/hd9var 15728640 810228 95% 13874 7% /var
/dev/hd3 6422528 1856680 72% 4035 1% /tmp
/proc - - - - - /proc
/dev/wdlv 55574528 30603740 45% 315925 5% /wd
/dev/dcclv 37748736 10042348 74% 364803 14% /dcc
/dev/userslv 1048576 1039616 1% 59 1% /users
10.9.9.105:/ifs/data/NAS_RMANBKP 418298160992 14912895200 97% 589129885906 94% /backup
10.9.12.25:/ORACLE_1 32212254720 9509599696 71% 706 1% /ORACLE_1
The file is definately editable:
/wd>ls -ltr /wd/backup.sh
-rwxr-xr-x 1 user1 dba 173 Apr 05 17:15 /wd/backup.sh
/wd>ls -lad /wd
drwxr-xr-x 1 root system 173 Apr 05 17:15 /wd/backup.sh
Kindly suggest how can I overcome the issue?
The error message is explicit: the user cannot write into the directory of the file, /wd; you can even see that in your ls output: drwxr-xr-x 1 root system says the directory is w-ritable only by root
The fix is very simple: add become: yes to your task, to enable privilege escalation when running that lineinfile task:
- name: Add Timeout Entry if not present
become: yes
lineinfile:
path: "/backup/backup.sh"
insertbefore: BOF
state: present
line: 'export TMOUT=50000'
Related
In the following path, i have the following logs:
When 10MB are reached for metricbeat file, it will go to write on metricbeat.1 and when this file size exceeds also, it will write to metricbeat.2 etc
[root# metricbeat]# ls -lorth
total 4.1M
-rwxrwxrwx 1 nifi 10 Aug 17 11:17 metricbeat.2
-rwxrwxrwx 1 nifi 10 Aug 17 11:17 metricbeat.1
-rwxrwxrwx 1 nifi 4.1M Aug 17 11:47 metricbeat
In NiFi (no cluster) I want to tail all the files that are stored on path
/logs/metricbeat/
I am using TailFile Processor with the following Configuration:
But, the main problem is that i am getting the following error:
'File to Tail' is invalid because There is no file to tail. Files must exist when starting this processor.
If i select the "Single Line" it gets the file "metricbeat"
Could you please tell me what i am doing wrong? Or how can i read all the "metricbeat" files from that path?
"Single File" mode does not require the file to exist before starting the processor, while "Multiple Files" mode does - hence the error you see.
I started saving redis-db snapshot by calling BGSAVE command in redis-cli.
It has started running but I keep getting these errors in the logs
[30853] 27 Jan 07:18:41.129 # Background saving error
[30853] 27 Jan 07:18:47.043 * 1 changes in 900 seconds. Saving...
[30853] 27 Jan 07:18:47.058 * Background saving started by pid 13204
[13204] 27 Jan 07:18:47.058 # Failed opening .rdb for saving: Permission denied
[30853] 27 Jan 07:18:47.158 # Background saving error
[30853] 27 Jan 07:18:53.070 * 1 changes in 900 seconds. Saving...
[30853] 27 Jan 07:18:53.085 * Background saving started by pid 13207
[13207] 27 Jan 07:18:53.085 # Failed opening .rdb for saving: Permission denied
[30853] 27 Jan 07:18:53.186 # Background saving error
[30853] 27 Jan 07:18:59.098 * 1 changes in 900 seconds. Saving...
[30853] 27 Jan 07:18:59.113 * Background saving started by pid 13210
[13210] 27 Jan 07:18:59.114 # Failed opening .rdb for saving: Permission denied
[30853] 27 Jan 07:18:59.213 # Background saving error
looks like the redis BGSAVE command is running indefinitely. How to stop this.
Also I tried checking for process pid by ps -aux| grep redis command.
13196 pts/11 S+ 0:00 grep --color=auto redis
30853 ? Ssl 1292:57 /usr/bin/redis-server *:6379
There is no process to kill.
EDIT: These are the permissions to redis folder and dump.rdb file
f: /var/lib/redis
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-xr-x redis redis redis
f: /var/lib/redis/dump.rdb
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-xr-x redis redis redis
-rw-rw-rw- redis redis dump.rdb
EDIT2: Got the answer. The problem was somehow the config parameters are changed. The dbfilename and dir values are changed.
Set these values to original through CONFIG SET command and now its working fine. Adding in-case somebody has same problem.
But the question is how did they change. Did this happen to anybody else?
Help me
Thanks
You can either try and fix the file permissions error (does the default save location exist and does redis have permission to write to it?) or you can disable saving with:
config set save ""
I have a script that I run manually every hour in my Laravel that's under this path:
/var/www/name/storage/scripts/getListOfClassesFromSubjects.pl
What I normally do is, I cd to /scripts/, and I manually run:
./getListOfClassesFromSubjects.pl
And the script works fine.
Today, I setup a crontab to automate this (obviously).
0,30 * * * * /var/www/name/storage/scripts/getListOfClassesFromSubjects.pl >> /var/www/name/storage/logs/schedulizer.log 2>&1
Within my logs are this:
DBD::SQLite::db prepare failed: no such table: subject_urls at /var/www/loop/storage/scripts/getListOfClassesFromSubjects.pl line 56.
Which is an anomaly because when I run the script manually, it's fine.
This is my database's permissions:
-rw-r--r-- 1 root root 11750400 Aug 4 12:30 database.sqlite
So I'm thinking this is the issue with the rwx permissions, so I changed the DB to 755:
-rwxr-xr-x 1 root root 11750400 Aug 4 12:30 database.sqlite
Still the same issue
For the path to the database, your code uses a relative path that assumes the current directory is the directory in which the script resides. It is not.
Instead of
"../database.sqlite"
use
use FindBin qw( $RealBin );
"$RealBin/../database.sqlite"
or
use FindBin qw( $RealBin );
chdir($RealBin);
"../database.sqlite"
I have partition structure like :
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda6 51606140 16939248 34142692 34% /
/dev/sda5 495844 72969 397275 16% /boot
/dev/sda7 113022648 57515608 49765728 50% /home
/dev/sda8 113022648 57515608 49765728 4% /mnt
while parsing directories content using readdir() - how to find out which file resides on what device?
readdir() invoked from root directory and parses the file name and prints its size.
like from device : /dev/sda6 and list the filenames under that partition.
When it reads contents from /home - it should display reading content from /dev/sda7 and list filenames
Please let me know,if you need more details/info
you can just do
df <file_name>
that will give you the device and partition for the particuar file
There is a st_dev member in struct stat, it should uniquely identify one partition.
Example in bash:
stat ~/.vimrc
File: `/home2//leonard/.vimrc' -> `local-priv/vimrc'
Size: 16 Blocks: 0 IO Block: 4096 symbolic link
Device: 802h/2050d Inode: 6818899 Links: 1
Access: (0777/lrwxrwxrwx) Uid: ( 1024/ leonard) Gid: ( 1024/ leonard)
Access: 2012-06-22 16:36:45.341371003 +0300
Modify: 2012-06-22 16:36:45.341371003 +0300
Change: 2012-06-22 16:36:45.341371003 +0300
The stat utility does no additional magic. Here is strace -vvv output:
lstat64("/home2//leonard/.vimrc", {st_dev=makedev(8, 2), st_ino=6818899, st_mode=S_IFLNK|0777, st_nlink=1, st_uid=1024, st_gid=1024, st_blksize=4096, st_blocks=0, st_size=16, st_atime=2012/06/22-16:36:45, st_mtime=2012/06/22-16:36:45, st_ctime=2012/06/22-16:36:45}) = 0
0x0802 is major 8(sd) partition 2, so /dev/sda2
In order to map this to actual partitions you can iterate /proc/mounts and stat all the devices (first column). The contents of /proc/mounts is just like the output of mount(1) except it comes directly from the kernel. Some distros symlink /etc/mtab to /proc/mounts.
Or you can parse /proc/partitions:
$ cat /proc/partitions
major minor #blocks name
8 0 976762584 sda
8 1 3998720 sda1
8 2 972762112 sda2
Of course /dev/sda might not actually exist, the device could be using a long udev name like /dev/disk/by-uuid/c4181217-a753-4cf3-b61d-190ee3981a3f. Major/Minor numbers should be a reliable unique identifier of a partition.
I have changed a CSS file, then committed it. Then updated it on another server. But the time of the updated file is time of the SVN update.
Is it possible to get the "Real" time - the one when the file change was saved on the first server?
Output of stat:
stat myfile.css
File: `myfile.css'
Size: 29731 Blocks: 64 IO Block: 4096 regular file
Device: fe11h/65041d Inode: 4411064 Links: 1
Access: (0660/-rw-rw----) Uid: ( 1118/ valk) Gid: ( 1010/developers)
Access: 2012-02-19 18:04:50.000000000 +0200
Modify: 2012-02-19 18:04:50.000000000 +0200
Change: 2012-02-19 18:04:50.000000000 +0200
Thanks
You can also configure Subversion to use commit-times by editing the
Subversions config file located at ~/.subversion/config (UNIX, Linux) respectively
%APPDATA%\subversion(Windows)
There are these lines (around line 100 in unmodified file):
### Set use-commit-times to make checkout/update/switch/revert
### put last-committed timestamps on every file touched.
# use-commit-times = yes
Just remove the "#" from the last displayed line.
Note this setting is active for all your workingcopies on this machine
Use svn info. It will give you something like:
Path: /XXXXX/myfile.css
Name: myfile.css
URL: svn+ssh://XXXXX/current/myfile.css
Repository Root: svn+ssh://XXXXX
Repository UUID: ed4dba2c-4d18-0410-83c2-a4e2ddc248c7
Revision: 3697
Node Kind: file
Schedule: normal
Last Changed Author: ocharlesworth
Last Changed Rev: 3654
Last Changed Date: 2011-11-22 00:08:53 +0000 (Tue, 22 Nov 2011)
Text Last Updated: 2011-12-15 11:39:55 +0000 (Thu, 15 Dec 2011)
Checksum: 395d2b79f528cccb58017a87a76f2e50